Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
1127 - Praslea
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Explicație = Sunt <code>8</code> parcele: <code>3</code> dintre ele au fost împărţite fraţilor şi verişorilor. Parcelele rămase pentru oşteni au toate lăţimea <code>2</code>. Dintre cele <code>3</code> parcele: parcela <code>2</code> are lăţimea <code>1</code>, parcela <code>5</code> are lăţimea <code>4</code> şi parcela <code>1</code> are lăţimea <code>1</code>. Pomul cu mere de aur se află la distanţa <code>7</code> faţă de marginea din stânga a grădinii. Sunt <code>3</code> parcele alăturate care au lăţimea egală cu <code>2</code> (parcelele numerotate cu <code>6</code>,@7@ şi <code>8</code>). Pomul se află în parcela cu numărul de ordine <code>5</code>. == Încărcare soluție == === Lipește codul aici === <syntaxhighlight lang="python" line="1"> const fs = require('fs'); class Parcela { constructor(indice, latime) { this.indice = indice; this.latime = latime; } } function cmp(a, b) { return a.indice < b.indice; } function main() { const input = fs.readFileSync('praslea.in', 'utf8').split('\n'); const [N, M, L] = input[0].split(' ').map(Number); const C = []; for (let i = 1; i <= M; i++) { const [indice, latime] = input[i].split(' ').map(Number); C.push(new Parcela(indice, latime)); } const P = Number(input[M + 1]); C.push(new Parcela(N + 1, 0)); C.sort(cmp); let max_parcele = N - C[M - 1].indice; let i = 0; let ok = 0; let indice_precedent = 0; let Pom = 0; while (i < M) { const alaturate = C[i].indice - indice_precedent - 1; max_parcele = Math.max(max_parcele, alaturate); if (!ok && P <= alaturate * L) { Pom = indice_precedent + Math.ceil(P / L); ok = 1; } else { if (alaturate > 0) P = P - alaturate * L; if (!ok && P <= C[i].latime) { Pom = C[i].indice; ok = 2; } else { P = P - C[i].latime; } } indice_precedent = C[i].indice; i++; } const fout = fs.createWriteStream('praslea.out'); fout.write(`${max_parcele}\n`); if (ok === 0) { Pom = C[M - 1].indice + Math.ceil(P / L); } fout.write(`${Pom}\n`); fout.end(); } </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width