QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#71617 | #1697. Balance Beam | He_Ren | 18.181818 | 25ms | 5732kb | C++23 | 1.2kb | 2023-01-11 16:28:41 | 2023-01-11 16:28:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
const int MAXN = 1e5 + 5;
struct Vector {
ll x, y;
Vector(void) {}
Vector(ll _x, ll _y): x(_x), y(_y) {}
};
Vector operator - (const Vector &p, const Vector &q) {
return Vector(p.x - q.x, p.y - q.y);
}
ll cross(const Vector &p, const Vector &q) {
return p.x * q.y - p.y * q.x;
}
int a[MAXN];
int main(void) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
static Vector h[MAXN];
int tp = 0;
h[++tp] = Vector(0, 0);
for (int i = 1; i <= n + 1; ++i) {
Vector cur(i, a[i]);
while (tp >= 2 && cross(cur - h[tp], cur - h[tp - 1]) <= 0)
--tp;
h[++tp] = cur;
}
const ll B = 1e5;
static ll ans[MAXN];
for (int i = 1; i < tp; ++i) {
ll dx = h[i + 1].x - h[i].x;
ll dy = h[i + 1].y - h[i].y;
for (int j = h[i].x; j < h[i + 1].x; ++j)
ans[j] = h[i].y * B
+ (__int128)dy * (j - h[i].x) * B / dx;
}
for (int i = 1; i <= n; ++i)
printf("%lld\n", ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 9.09091
Accepted
time: 1ms
memory: 3624kb
input:
2 1 3
output:
150000 300000
result:
ok 2 lines
Test #2:
score: 9.09091
Accepted
time: 24ms
memory: 5192kb
input:
100000 10550 10166 14944 34729 60262 25398 4608 4103 101193 91415 63390 56440 54875 168733 55861 115845 204889 86170 228991 45049 188746 174299 157006 230942 301295 28758 261824 283112 3483 361548 373598 385647 261775 110588 350711 61727 397275 359292 469989 100405 262091 249753 383032 300999 521216...
output:
1205240000 2410480000 3615720000 4820960000 6026200000 7231433333 8436666666 9641900000 10847133333 12052366666 13257600000 14462833333 15668066666 16873300000 18078500000 19283700000 20488900000 21694000000 22899100000 24104166666 25309233333 26514300000 27719366666 28924433333 30129500000 31334560...
result:
ok 100000 lines
Test #3:
score: 0
Wrong Answer
time: 22ms
memory: 4852kb
input:
100000 96 69 618 440 1643 2449 2117 73 470 4080 1853 1106 2589 4981 6118 4134 4702 3077 2592 8155 8562 6144 9375 5120 3709 18 11000 11405 8836 12214 11637 5468 10706 11093 14235 9866 15042 12766 15586 14034 11827 17058 10880 17863 15006 11739 15698 307 6830 17584 2846 21082 14912 21886 6967 7840 110...
output:
40816666 81633333 122450000 163266666 204083333 244900000 285675000 326450000 367225000 408000000 448760000 489520000 530280000 571040000 611800000 652540000 693280000 734020000 774760000 815500000 856200000 896850000 937500000 978125000 1018750000 1059375000 1100000000 1140500000 1180950000 1221400...
result:
wrong answer 2177th lines differ - expected: '46519166666', found: '46519166667'
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 3648kb
input:
200 86857 23812 79982 44721 28718 48332 86220 19866 23758 48884 24781 92876 58394 30676 50939 1246 77228 69833 9109 556 16565 75867 28884 59093 85906 14369 45990 60314 18861 30445 70991 5717 54256 50973 66796 99332 99297 53016 19197 39420 1899 60337 48662 60285 91012 15966 61531 68233 85791 87005 68...
output:
8685700000 8740418181 8795136363 8849854545 8904572727 8959290909 9014009090 9068727272 9123445454 9178163636 9232881818 9287600000 9314500000 9341400000 9368300000 9395200000 9422100000 9449000000 9475900000 9502800000 9529700000 9556600000 9583500000 9610400000 9637300000 9664200000 9691100000 971...
result:
wrong answer 37th lines differ - expected: '9932740476', found: '9932740477'
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
5000 72083 34770 50448 76733 68071 44356 12800 25882 23411 61847 16071 72060 55263 60945 34424 53020 42724 63542 67935 83270 33043 38718 83427 34388 62968 70173 21833 51799 79193 53222 42211 67634 87991 9024 60726 72427 53373 89884 14667 93149 51730 30731 81567 6986 91668 15990 76371 50757 95891 443...
output:
7208300000 7363300000 7518300000 7673300000 7719534693 7765769387 7812004081 7858238775 7904473469 7950708163 7996942857 8043177551 8089412244 8135646938 8181881632 8228116326 8274351020 8320585714 8366820408 8413055102 8459289795 8505524489 8551759183 8597993877 8644228571 8690463265 8736697959 878...
result:
wrong answer 1243rd lines differ - expected: '9993897589', found: '9993897590'
Test #6:
score: 0
Wrong Answer
time: 16ms
memory: 4872kb
input:
100000 42613 39648 57462 23706 42581 34382 11589 50774 50931 75743 25387 27284 87003 6993 79687 62698 48230 55958 56398 32739 15357 23709 43837 63327 75293 19706 99184 8645 97561 7812 79584 40173 63825 53405 63879 6405 87786 91833 73537 55075 83934 98924 98725 70936 22282 78411 49993 86870 34369 639...
output:
4261300000 5003750000 5746200000 6041610000 6337020000 6632430000 6927840000 7223250000 7518660000 7814070000 8109480000 8404890000 8700300000 8787307142 8874314285 8961321428 9048328571 9135335714 9222342857 9309350000 9396357142 9483364285 9570371428 9657378571 9744385714 9831392857 9918400000 991...
result:
wrong answer 68987th lines differ - expected: '9999899969', found: '9999899970'
Test #7:
score: 0
Wrong Answer
time: 22ms
memory: 4940kb
input:
100000 126 176 450 531 845 960 230 2029 2013 2441 393 898 2963 396 737 1576 4686 4531 2548 2752 2937 3500 5263 3681 4832 139 6997 7064 6827 1909 996 2040 10621 7628 9694 2289 5908 5695 1652 12862 2098 5532 10892 8000 10477 14202 1137 306 4843 14167 4747 270 6973 12124 1864 8646 5054 11755 14676 8514...
output:
33163218 66326436 99489655 132652873 165816091 198979310 232142528 265305747 298468965 331632183 364795402 397958620 431121839 464285057 497448275 530611494 563774712 596937931 630101149 663264367 696427586 729590804 762754022 795917241 829080459 862243678 895406896 928570114 961733333 994896551 102...
result:
wrong answer 99422nd lines differ - expected: '2884542062068', found: '2884542062069'
Test #8:
score: 0
Wrong Answer
time: 8ms
memory: 4832kb
input:
100000 76 320 230 1049 962 705 1290 1673 1370 572 873 3333 1530 3522 2985 4212 937 3528 3357 3933 6327 2801 5408 2537 1003 391 6600 6753 1950 4710 2494 3941 3426 6421 7121 7049 4959 8943 4434 1871 6061 528 7278 1237 6495 13185 9374 273 10115 9355 11733 4274 7866 16015 7578 12801 12699 9034 6295 1159...
output:
30810599 61621198 92431797 123242396 154052995 184863594 215674193 246484792 277295391 308105990 338916589 369727188 400537788 431348387 462158986 492969585 523780184 554590783 585401382 616211981 647022580 677833179 708643778 739454377 770264976 801075576 831886175 862696774 893507373 924317972 955...
result:
wrong answer 99861st lines differ - expected: '1645801574468', found: '1645801574469'
Test #9:
score: 0
Wrong Answer
time: 19ms
memory: 4812kb
input:
100000 285 1191 4032 4253 2028 6342 6259 129 12406 10505 1861 7574 7081 13668 20727 13386 18752 17757 26939 12650 7879 6210 28257 21004 28122 36862 103 26569 7459 40624 12927 12953 26705 18007 37564 38149 13381 9977 51047 50996 38898 13414 59125 36150 15396 49423 20199 1043 5212 62121 63394 33190 56...
output:
141784210 283568421 425352631 567136842 708921052 850705263 992489473 1134273684 1276057894 1417842105 1559626315 1701410526 1843194736 1984978947 2126763157 2268547368 2410331578 2552115789 2693900000 2835657142 2977414285 3119171428 3260928571 3402685714 3544442857 3686200000 3827956410 3969712820...
result:
wrong answer 99809th lines differ - expected: '12009802445595', found: '12009802445596'
Test #10:
score: 0
Wrong Answer
time: 19ms
memory: 5732kb
input:
100000 3700 2515 19050 13718 42454 50943 15036 21588 17968 63237 68840 49149 110365 44575 118371 118979 138079 110883 128494 99640 146984 60252 166941 100574 30480 154004 219764 151278 163270 4936 62463 187683 57978 207856 276102 128289 122059 109461 331073 329012 312878 348679 289155 120329 119050 ...
output:
849080000 1698160000 2547240000 3396320000 4245400000 5094300000 5943185714 6792071428 7640957142 8489842857 9338728571 10187614285 11036500000 11885376923 12734253846 13583130769 14432007692 15280884615 16129761538 16978638461 17827515384 18676392307 19525269230 20374146153 21223023076 22071900000 ...
result:
wrong answer 99989th lines differ - expected: '74998792523076', found: '74998792523077'
Test #11:
score: 0
Wrong Answer
time: 25ms
memory: 4868kb
input:
100000 234 72 826 1282 2883 6351 9173 4949 12623 4562 8352 9630 15317 17653 5224 17730 22248 11805 14165 9730 21425 935 21759 33803 31229 1903 13560 42166 1775 8762 8291 15655 15439 11824 27529 54213 21905 3239 31119 20433 22022 37367 42523 4878 40568 49055 61970 53282 17789 39217 76800 6074 7198 73...
output:
150592857 301185714 451778571 602371428 752964285 903557142 1054150000 1204742857 1355335714 1505928571 1656521428 1807114285 1957707142 2108300000 2258892857 2409485714 2560078571 2710671428 2861264285 3011857142 3162450000 3313042857 3463635714 3614228571 3764821428 3915414285 4066007142 421660000...
result:
wrong answer 85435th lines differ - expected: '6409201683333', found: '6409201683334'