QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#439761 | #4403. Measures | SmilingBraniac# | 10 | 226ms | 12352kb | C++14 | 1.1kb | 2024-06-12 17:34:49 | 2024-06-12 17:34:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll s, ll e, ll sz, ll d) {
return (d * (sz - 1) - (e - s)) / 2;
}
ll solve(int n, int d, vector<ll> v) {
d *= 2;
for (ll& i : v) i *= 2;
sort(v.begin(), v.end());
stack<ll> s, e, sz;
for (int i = 0; i < n; ++i) {
ll a = v[i], b = v[i], cnt = 1;
while (!s.empty()) {
ll add = f(s.top(), e.top(), sz.top(), d), neg = f(a, b, cnt, d);
if (e.top() + add + d <= a - neg) break;
a = s.top();
cnt += sz.top();
s.pop(); e.pop(); sz.pop();
}
s.push(a); e.push(b); sz.push(cnt);
}
ll ans = 0;
while (!s.empty()) {
ans = max(ans, f(s.top(), e.top(), sz.top(), d));
s.pop(); e.pop(); sz.pop();
}
return ans;
}
int main() {
int n, q, d; cin >> n >> q >> d;
vector<ll> v(n);
for (ll& i : v) cin >> i;
while (q--) {
ll x; cin >> x;
v.push_back(x);
ll ans = solve(v.size(), d, v);
cout << ans / 2;
if (ans & 1) cout << ".5";
cout << ' ';
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 3568kb
input:
2000 10 1845 533219610 452539353 832124174 883897563 447321676 368976465 166536135 758380924 920827481 313174994 781707618 815047867 925081003 325012331 69086835 637564067 429273345 781597586 376641056 72157101 36547962 656170271 772458737 707141316 33546435 166034841 747620387 663158697 852912826 9...
output:
841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5
result:
ok single line: '841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 '
Test #2:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
2000 10 18453 15731 19943 24157 28373 32591 36811 41033 45257 49483 53711 57941 62173 66407 70643 74881 79121 83363 87607 91853 96101 100351 104603 108857 113113 117371 121631 125893 130157 134423 138691 142961 147233 151507 155783 160061 164341 168623 172907 177193 181481 185771 190063 194357 19865...
output:
12242000 12247120.5 12252240 12257358.5 12262476 12267592.5 12272708 12277822.5 12282936 12288048.5
result:
ok single line: '12242000 12247120.5 12252240 1...12277822.5 12282936 12288048.5 '
Test #3:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
2000 10 183 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 687063759 68706375...
output:
183000 183091.5 183183 183274.5 183366 183457.5 183549 183640.5 183732 183823.5
result:
ok single line: '183000 183091.5 183183 183274....83549 183640.5 183732 183823.5 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
2000 10 7839 1104882 11557593 17250624 872120 2610939 3168410 19793876 15923377 12558592 8012464 3832981 20410098 21176008 11809662 16650803 3325375 18801530 10601271 19898055 2718936 16771672 20906144 738601 942896 6133368 7083258 5682092 20405279 11421184 22198704 8041726 5327160 1116282 13053727 ...
output:
6553 6553 6553 6553 6553 6553 6553 6553 6553 6553
result:
ok single line: '6553 6553 6553 6553 6553 6553 6553 6553 6553 6553 '
Test #5:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
2000 10 739 1 740 1479 2218 2957 3696 4435 5174 5913 6652 7391 8130 8869 9608 10347 11086 11825 12564 13303 14042 14781 15520 16259 16998 17737 18476 19215 19954 20693 21432 22171 22910 23649 24388 25127 25866 26605 27344 28083 28822 29561 30300 31039 31778 32517 33256 33995 34734 35473 36212 36951 ...
output:
0 0 0 0 0 0 0 0 0 0
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 '
Test #6:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
2000 10 693863 1 1000000000 480943 999669197 565391 999666029 886463 999291533 1249015 998911315 1478174 998873791 1643910 998800730 2090062 998349218 2347718 998157249 2733042 997720305 3169022 997381640 3277592 997088828 3497572 997009332 3567289 996980677 3701759 996594181 3962951 996234981 42561...
output:
220646989.5 220646989.5 220840733 220840733 221133776.5 221133776.5 221294708 221294708 221444150.5 221444150.5
result:
ok single line: '220646989.5 220646989.5 220840...294708 221444150.5 221444150.5 '
Test #7:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
2000 10 63 59351 86565 119326 96018 26653 54561 83792 99231 64897 45739 132 83986 21490 68362 54246 43601 83102 19156 36418 11788 103451 119074 118824 29552 5109 56957 85307 91544 105780 50721 35410 17960 118572 117811 4543 103636 72580 1203 95893 119008 101306 107103 33580 47377 40325 49273 635 668...
output:
3 3 3 3 3 3 3 3 3 3
result:
ok single line: '3 3 3 3 3 3 3 3 3 3 '
Test #8:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
2000 10 56903845 127114 197411 1751728 1874621 2165212 3716390 3843654 3933149 4159859 5120856 5188293 5242118 7085138 7775976 12194564 12602079 13461967 14456365 14904923 15391671 19752717 20090124 20139792 20559656 20693437 21047553 21312167 22103298 22355758 22697350 22706420 24725181 26596102 26...
output:
56405845112.5 56434272288 56462364146.5 56490797101 56519140756 56547265108.5 56575660598 56603615491.5 56632007948.5 56660232802.5
result:
ok single line: '56405845112.5 56434272288 5646....5 56632007948.5 56660232802.5 '
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 14
Accepted
time: 181ms
memory: 11204kb
input:
200000 10 128 853561279 93820692 821887507 753094209 227461682 691969137 519378763 296675314 646705609 727762559 98496302 959430593 403972779 982596953 775241610 209602833 112152326 762927950 619981024 764326855 379819398 392809293 145648647 960106249 514225957 952027167 428472167 571874662 95085242...
output:
167 167 167 167 167 167 167 167 167 167
result:
ok single line: '167 167 167 167 167 167 167 167 167 167 '
Test #10:
score: 0
Accepted
time: 159ms
memory: 7788kb
input:
200000 10 6850386 2684591 6734660 10784731 14834804 18884879 22934956 26985035 31035116 35085199 39135284 43185371 47235460 51285551 55335644 59385739 63435836 67485935 71536036 75586139 79636244 83686351 87736460 91786571 95836684 99886799 103936916 107987035 112037156 116087279 120137404 124187531...
output:
684538602443.5 684542027636.5 684545452829.5 684548878022.5 684552303215.5 684555728408.5 684559153601.5 684562578794.5 684566003987.5 684569429180.5
result:
ok single line: '684538602443.5 684542027636.5 ... 684566003987.5 684569429180.5 '
Test #11:
score: 0
Accepted
time: 79ms
memory: 9172kb
input:
200000 10 4486 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 857631169 85763...
output:
448600000 448602243 448604486 448606729 448608972 448611215 448613458 448615701 448617944 448620187
result:
ok single line: '448600000 448602243 448604486 ... 448615701 448617944 448620187 '
Test #12:
score: 0
Accepted
time: 226ms
memory: 9160kb
input:
200000 10 697048 1615380 101180 641216 742032 1567593 600170 241860 1021953 1149207 2100296 1272309 1354964 2029412 597565 887502 976008 1404381 1837659 632700 50460 932908 1020384 126420 1061226 1670138 197328 1718544 1307694 811296 1881376 1111143 965041 171096 1496688 1765977 1162560 845980 17225...
output:
69204802152.5 69205150676.5 69205499200.5 69205847724.5 69206196248.5 69206544772.5 69206893296.5 69207241820.5 69207590344.5 69207938868.5
result:
ok single line: '69204802152.5 69205150676.5 69....5 69207590344.5 69207938868.5 '
Test #13:
score: 0
Accepted
time: 80ms
memory: 12352kb
input:
200000 10 12 1 13 25 37 49 61 73 85 97 109 121 133 145 157 169 181 193 205 217 229 241 253 265 277 289 301 313 325 337 349 361 373 385 397 409 421 433 445 457 469 481 493 505 517 529 541 553 565 577 589 601 613 625 637 649 661 673 685 697 709 721 733 745 757 769 781 793 805 817 829 841 853 865 877 8...
output:
0 0 0 0 0 0 0 0 0 0
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 '
Test #14:
score: -14
Wrong Answer
time: 120ms
memory: 10504kb
input:
200000 10 863 1 1000000000 3394 999998271 4669 999994786 9232 999991037 11967 999988500 12327 999983865 16284 999979370 19250 999975638 20409 999972351 24387 999971383 27077 999970128 29216 999965864 32154 999962202 37088 999961247 38901 999957667 41513 999956460 44567 999955186 47435 999950881 4956...
output:
1559.5 1559.5 1559.5 1559.5 1559.5 1559.5 1559.5 1559.5 1559.5 1559.5
result:
wrong answer 1st lines differ - expected: '1662 1662 1662 1662 1662 1662 1662 1662 1662 1662', found: '1559.5 1559.5 1559.5 1559.5 15....5 1559.5 1559.5 1559.5 1559.5 '
Subtask #3:
score: 0
Time Limit Exceeded
Test #17:
score: 0
Time Limit Exceeded
input:
0 200000 1289 3822 6378 8930 10621 14339 15484 27804 30714 47103 51268 51740 57420 74974 81161 81292 82797 84329 92397 96558 102781 108313 117355 117730 121011 121917 123170 124479 132083 144850 152609 153404 161406 162584 163062 172029 172074 172504 178451 185861 197247 197729 204944 223883 245287...
output:
0 0 0 0 0 72 72 72 72 72 408.5 408.5 408.5 408.5 579 471 408.5 408.5 408.5 408.5 408.5 408.5 457 457 457 457 457 457 457 457 457 457 457 461 461 622 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051...
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #34:
score: 0
Time Limit Exceeded
input:
0 200000 1289 582772771 851704216 915624354 601264573 510202549 844706968 795870015 897865316 665295826 172582259 59358299 239645315 343442424 973625659 840972987 546781500 897704802 602265737 968590815 561687707 728916679 417806750 143659623 620408739 86393298 403049850 578760184 735385586 7656173...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...