QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#369426 | #1643. Archeologists | Lynkcat | AC ✓ | 41ms | 9624kb | C++17 | 781b | 2024-03-28 08:52:12 | 2024-03-28 08:52:13 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
#define int ll
//#define N
using namespace std;
const int N=300005;
int n,a[N],s[N],ans;
void BellaKira()
{
cin>>n;
for (int i=1;i<=n;i++)
cin>>a[i],s[i]=s[i-1]+a[i];
priority_queue<int>q;
q.push(0);
for (int i=1;i<=n;i++)
{
if (q.size()&&s[i]+q.top()>0)
{
ans+=s[i]+q.top();
q.push(-s[i]);
q.pop();
}
q.push(-s[i]);
}
cout<<ans<<'\n';
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5632kb
input:
5 1 3 -4 2 1
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5828kb
input:
4 1 1 -2 3
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5588kb
input:
5 -1 -3 0 -5 -4
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5572kb
input:
100 0 -269 232 121 -422 -439 -69 478 -385 -351 38 271 -100 -153 -438 -143 41 50 200 60 92 266 340 282 -212 73 -337 70 -439 291 -191 428 303 -439 -92 -174 247 -398 2 -72 199 141 -145 -138 -226 34 120 -265 -351 20 -366 330 -381 -234 239 29 -358 -371 100 96 -179 249 380 15 201 -492 -159 -495 -366 -302 ...
output:
35977
result:
ok single line: '35977'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5520kb
input:
100 376 200 164 331 396 -419 186 358 318 344 -485 58 -185 -499 -216 489 -149 -43 485 -114 -288 -489 -495 335 385 -152 -495 -64 476 438 292 -481 83 -242 -236 -34 -183 230 474 446 463 434 -481 445 220 -491 -418 72 90 -40 302 -223 251 432 118 319 -493 -209 291 203 -200 -490 -435 -260 332 -434 223 300 -...
output:
48045
result:
ok single line: '48045'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5676kb
input:
100 -313 -36 144 -76 368 -176 -8 112 52 -161 -125 145 -101 5 -308 -49 -71 26 -288 211 195 97 186 107 141 238 292 -32 -60 120 -18 288 184 13 299 -370 34 -166 272 -208 204 275 -161 -85 338 147 -54 8 -170 -143 -142 279 171 -233 -47 106 -394 -125 176 -83 -15 -319 -267 -98 -346 -161 37 244 148 322 139 80...
output:
52502
result:
ok single line: '52502'
Test #7:
score: 0
Accepted
time: 0ms
memory: 5516kb
input:
100 -263 -142 260 72 233 413 218 -30 33 97 74 416 -51 -213 417 -345 356 372 85 358 -414 -10 369 -425 245 300 442 98 -374 105 -226 385 77 458 31 106 -75 134 -470 441 -57 110 332 -434 65 388 127 427 121 -377 -187 -290 -282 -436 -177 -40 -293 275 289 476 -170 -150 125 -235 132 -205 395 478 -43 -47 -318...
output:
104040
result:
ok single line: '104040'
Test #8:
score: 0
Accepted
time: 0ms
memory: 5612kb
input:
100 -285 -256 -109 -129 497 -96 286 275 -200 -161 -156 -368 479 422 64 -196 402 185 -114 8 26 439 76 179 -457 -182 -453 -334 438 449 227 246 -39 443 -98 194 159 105 -291 194 392 311 -71 430 296 239 -388 429 -118 -215 124 -33 -257 354 -335 -286 170 -21 -438 -375 -401 -22 43 466 90 29 434 431 -260 194...
output:
138349
result:
ok single line: '138349'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5652kb
input:
100 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...
output:
2550000
result:
ok single line: '2550000'
Test #10:
score: 0
Accepted
time: 2ms
memory: 6076kb
input:
10000 -1274 -2991 182 -4874 4603 2872 2444 1624 -4616 -1007 -882 -2944 2538 1107 4134 -1636 -2325 2088 4951 -1800 -3119 -3085 -3200 808 -236 -356 -2499 3414 -261 -4334 4899 -2886 2014 3019 -259 -2248 -545 -2750 -242 -2536 -3227 -2675 -3231 4357 1154 2170 3614 4299 -3633 3682 -3890 2690 1491 3677 145...
output:
199899353
result:
ok single line: '199899353'
Test #11:
score: 0
Accepted
time: 2ms
memory: 5864kb
input:
10000 -4800 2893 2719 4158 4791 733 4130 4194 -4745 -4525 -4759 -1673 -1963 3591 -1922 3264 -3983 3838 -1119 4620 4707 2501 -2222 -4267 -2718 -3848 2426 -4686 -3593 -4530 -4462 1067 231 584 3862 -2219 3017 3534 3644 4906 -3339 4669 738 -3877 -2412 2156 -4994 4718 -262 2666 -3462 -4559 222 932 -2492 ...
output:
557524676
result:
ok single line: '557524676'
Test #12:
score: 0
Accepted
time: 2ms
memory: 5832kb
input:
10000 4872 -1054 3601 -373 490 1283 -1775 4864 -2516 4513 -4642 -839 3461 872 -3982 -4053 4064 -581 429 958 431 -4324 -1513 -1994 3732 3433 -21 3187 -195 -3194 3612 -2037 -2430 3668 -369 871 4739 -2259 3856 -4288 3012 -2833 -4061 4681 -1753 604 2448 -1366 3913 4162 581 -2334 3615 -3356 -4967 4283 -1...
output:
641238704
result:
ok single line: '641238704'
Test #13:
score: 0
Accepted
time: 0ms
memory: 5836kb
input:
10000 -4403 -1750 -2813 -1606 -2909 1768 2406 199 -2215 -2268 125 -3199 594 -73 1598 2113 -2887 -3554 3939 -2359 -3560 2601 -3481 -295 -3484 351 -376 -2744 4681 1457 1174 500 -4425 -3499 -1199 -4146 511 2729 -968 3981 -1600 -676 -2439 -677 -3641 3339 -1356 4030 1263 -3995 -289 1755 1570 -4153 1950 3...
output:
825849477
result:
ok single line: '825849477'
Test #14:
score: 0
Accepted
time: 0ms
memory: 5828kb
input:
10000 1592 -1249 1133 1803 1833 4557 1378 130 -4148 -1130 -2104 -3657 -4901 -875 -74 -4790 598 -4233 -927 -1867 2716 1015 -830 -1656 -4754 -4115 3552 -89 -2514 2623 404 -1149 1447 -3295 2101 -4605 1004 -2977 -2521 -1013 2148 2935 3959 -2805 -4873 2619 -3185 2947 4515 -4962 3993 3875 4872 3600 -2107 ...
output:
739499123
result:
ok single line: '739499123'
Test #15:
score: 0
Accepted
time: 2ms
memory: 6092kb
input:
10000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ...
output:
2500500000000
result:
ok single line: '2500500000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 5856kb
input:
20000 -403603 126737 206322 36864 -160778 -183504 214818 -209523 -294570 161802 388085 -459159 45975 254024 112603 187078 -107744 346826 182041 66124 -235425 -48444 154118 -1200 -6511 116103 46604 138010 104947 248283 52258 337503 -87333 -291981 -101097 -264867 266733 -352662 121802 69467 259256 -18...
output:
2733609815785
result:
ok single line: '2733609815785'
Test #17:
score: 0
Accepted
time: 0ms
memory: 5956kb
input:
30000 313869 308682 252877 -313097 176477 -1839 79006 157104 -128431 -70122 192165 231472 276886 226574 -311495 -199118 211753 -93595 -82367 282227 365260 103131 -140881 223449 64304 142016 269142 46491 67441 169360 153039 -72555 -259421 224194 57852 -32510 74589 -76152 -44549 139542 100768 -39319 7...
output:
13062624844829
result:
ok single line: '13062624844829'
Test #18:
score: 0
Accepted
time: 7ms
memory: 6184kb
input:
50000 -9625 156594 -166650 385001 -31178 441232 -108286 111504 6365 -192361 87487 72446 220168 350304 -243174 -139138 449541 -108194 -105337 136686 200018 171631 -336074 319959 -71260 94121 -12325 -346512 58454 266157 -18245 70823 45687 -6267 205748 -38562 117141 -51128 -31443 -100988 177400 -126008...
output:
32672162625896
result:
ok single line: '32672162625896'
Test #19:
score: 0
Accepted
time: 4ms
memory: 8716kb
input:
80000 -395544 249488 -162360 -27308 -148113 33659 111786 239185 162677 455275 93256 272173 181238 -435930 359519 -27667 -320961 291702 -238387 -264993 -28278 149165 421149 289879 19193 116807 291456 -29741 226634 122392 -99095 -458893 46119 -136013 -293877 51642 -252275 -68948 -203878 -421750 67367 ...
output:
15841003745322
result:
ok single line: '15841003745322'
Test #20:
score: 0
Accepted
time: 40ms
memory: 9440kb
input:
250000 -199099 -267128 383354 -311525 429930 -453248 257863 -410374 -357214 174476 465328 316052 396737 242400 225162 -347058 229663 -216576 83063 -471597 -468620 -477267 38682 -420738 384798 469802 327269 284979 228674 482666 8879 406553 97689 46272 250904 -396375 -466278 250817 -134592 -439402 -17...
output:
2660840568910
result:
ok single line: '2660840568910'
Test #21:
score: 0
Accepted
time: 40ms
memory: 9624kb
input:
250000 159200 -124998 113330 180318 183302 455775 137878 13014 -414854 -113065 -210480 -365759 -490183 -87584 -7438 -479088 59808 -423373 -92774 -186735 271656 101514 -83037 -165675 -475494 -411521 355261 -8925 -251443 262358 40437 -114926 144759 -329504 210120 -460500 100414 -297796 -252109 -101371...
output:
3914729477980
result:
ok single line: '3914729477980'
Test #22:
score: 0
Accepted
time: 41ms
memory: 9512kb
input:
250000 -222426 51806 315223 123395 -65793 -317189 -142045 -214958 89372 158141 -358804 -405669 54457 171823 -282594 -478519 -378285 247370 39111 -420843 262601 -471809 39256 499072 -490469 454773 -438476 -94672 12692 -193628 170858 6297 -289726 -429207 -80521 -143285 -297292 -198492 212195 441364 41...
output:
4622417852819
result:
ok single line: '4622417852819'
Test #23:
score: 0
Accepted
time: 41ms
memory: 9492kb
input:
250000 356131 183955 -166561 -437893 -112417 -284178 430303 220579 -451238 318587 90869 -245457 -182928 -309409 -148011 -240319 -488133 -89355 -86718 -455025 453198 -101138 29355 -264606 -189344 51421 206348 451580 100816 -96612 -143445 311454 -200216 44141 461457 -313842 225720 230925 -452009 46813...
output:
5440497581690
result:
ok single line: '5440497581690'
Test #24:
score: 0
Accepted
time: 36ms
memory: 9488kb
input:
250000 87341 -231938 279935 414999 323920 225095 -236467 408683 -236193 263210 -235425 -374292 -112336 336634 -218924 -427232 131316 83617 80132 174875 184713 -60138 -176617 69601 -19801 357651 331360 -390931 -436917 95567 289076 -270344 34752 -360458 -125919 -344513 -69116 289386 -91666 -318651 406...
output:
8872379753735
result:
ok single line: '8872379753735'
Test #25:
score: 0
Accepted
time: 41ms
memory: 9556kb
input:
250000 -451705 154024 83583 -169278 -401638 131389 350126 -349240 -444377 -373564 454170 -224752 -367029 28303 -444880 59166 30971 -475978 465916 -486999 371286 -453121 367306 -51808 -474167 -492974 -386084 168031 -310682 267560 49688 -334993 316483 145142 235365 282191 370030 -444454 -325815 -75062...
output:
7268467258712
result:
ok single line: '7268467258712'
Test #26:
score: 0
Accepted
time: 35ms
memory: 9456kb
input:
250000 -155183 304502 -445947 -374425 89793 29192 -73905 -151954 115389 -55911 222092 18262 74731 136725 485252 303156 -79128 359404 306989 -431476 205707 285867 222592 196704 39511 -356722 445883 -88399 -265070 204417 490722 -227735 161055 93474 204470 423357 -136533 -229636 -89130 232228 210862 -8...
output:
13568293048752
result:
ok single line: '13568293048752'
Test #27:
score: 0
Accepted
time: 41ms
memory: 9512kb
input:
250000 195817 -217293 254118 89938 334832 -355299 -203414 -153619 -6090 -7805 417318 -339996 -150086 336413 -180317 23999 -257576 -391125 -399323 60118 -481094 116309 275227 -270865 -324411 84679 424056 20976 -106137 22384 455224 375740 -346990 24959 9417 -163854 -446871 86907 -105571 432701 334699 ...
output:
12226073814845
result:
ok single line: '12226073814845'
Test #28:
score: 0
Accepted
time: 37ms
memory: 9408kb
input:
250000 266611 100921 -142246 -87649 -48879 219292 -169044 -347388 299416 475977 -240463 -70176 -36919 142907 300140 -161778 81774 -376587 434298 430416 409035 -314927 389482 125338 191238 -37879 -33257 123680 -112220 98957 -171094 -367048 330559 -305137 297746 -31391 27330 460857 -404939 -429797 -20...
output:
17952780671462
result:
ok single line: '17952780671462'
Test #29:
score: 0
Accepted
time: 25ms
memory: 9460kb
input:
250000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 10000...
output:
15625125000000000
result:
ok single line: '15625125000000000'