QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134240 | #2283. Decelerating Jump | Yarema# | AC ✓ | 18ms | 76124kb | C++17 | 1.0kb | 2023-08-03 15:22:13 | 2023-08-03 15:22:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const LL INF = 1e9 + 7;
const int N = 3047;
LL dp[N][N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
VI a(n);
FOR (i, 0, n) cin >> a[i];
FOR (i, 0, N)
{
FOR (j, 0, N) dp[i][j] = -INF * INF;
}
dp[0][n - 1] = a[0];
FOR (i, 0, n)
{
LL mx = -INF * INF;
FOR (j, n - 1 - i, n) mx = max(mx, dp[i][j]);
RFOR (j, n, i + 1)
{
dp[j][j - i] = max(dp[j][j - i], mx + a[j]);
mx = max(mx, dp[i][n - 1 - i - (n - j)]);
}
}
LL ans = -INF * INF;
FOR (i, 0, n) ans = max(ans, dp[n - 1][i]);
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 76028kb
input:
1000 1 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...
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 4ms
memory: 75996kb
input:
1000 1 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...
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 4ms
memory: 76032kb
input:
1000 1 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...
output:
7
result:
ok single line: '7'
Test #4:
score: 0
Accepted
time: 1ms
memory: 76032kb
input:
1000 1 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...
output:
12
result:
ok single line: '12'
Test #5:
score: 0
Accepted
time: 14ms
memory: 76048kb
input:
1000 1 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 1 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...
output:
27
result:
ok single line: '27'
Test #6:
score: 0
Accepted
time: 7ms
memory: 75992kb
input:
1000 1 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 1 0 0 0 0 0 0 0...
output:
35
result:
ok single line: '35'
Test #7:
score: 0
Accepted
time: 4ms
memory: 76096kb
input:
2 0 0
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 3ms
memory: 76048kb
input:
2 -1 -9
output:
-10
result:
ok single line: '-10'
Test #9:
score: 0
Accepted
time: 1ms
memory: 76064kb
input:
10 -1 0 1 0 0 0 1 1 1 -1
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 3ms
memory: 76008kb
input:
20 -2 -2 -1 -1 -2 1 0 1 2 3 -1 2 1 3 2 3 -1 -2 -1 3
output:
14
result:
ok single line: '14'
Test #11:
score: 0
Accepted
time: 3ms
memory: 76000kb
input:
10 3 10 -2 -9 4 -7 5 -7 -4 -5
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 5ms
memory: 75996kb
input:
50 -8 -3 -9 -9 -4 -8 7 -4 -10 -4 8 -9 -6 1 7 2 0 -3 7 3 -7 -9 -9 -9 6 -7 -2 -10 2 8 -10 -5 6 -4 -3 7 -8 -6 9 5 3 -4 9 1 10 8 0 -1 2 6
output:
82
result:
ok single line: '82'
Test #13:
score: 0
Accepted
time: 4ms
memory: 76060kb
input:
100 -64 65 -52 -25 39 -83 23 30 35 51 22 73 20 -18 -29 90 44 28 -34 -88 -79 -49 57 -63 86 -6 -92 28 44 41 73 8 -83 18 -25 40 29 87 50 22 -5 96 99 -74 60 -18 92 21 -65 -78 -17 -25 -8 49 69 -78 -82 92 83 -14 33 90 57 19 65 -50 -19 -77 74 -11 54 21 72 -55 -66 -43 -44 94 -27 46 -74 64 -8 -45 -78 14 -6 -...
output:
834
result:
ok single line: '834'
Test #14:
score: 0
Accepted
time: 1ms
memory: 76000kb
input:
200 -592 -939 223 74 -372 736 38 -455 735 -998 422 331 -740 142 38 -561 70 765 764 -839 -882 373 -174 938 -679 -33 596 98 -732 142 89 981 -743 -284 790 -289 -908 -830 -666 122 314 299 -192 545 119 -842 -113 934 -580 -72 60 -349 659 -562 885 835 629 -888 366 -245 -260 25 -193 683 -734 979 209 219 922...
output:
14459
result:
ok single line: '14459'
Test #15:
score: 0
Accepted
time: 0ms
memory: 76032kb
input:
300 -1282 5441 4865 -1420 -8118 6740 -2338 8435 -1095 3910 -9689 5258 -6414 8818 -1922 4168 6575 3345 -7739 -1709 -2456 -129 -9151 -4377 -9100 -1500 7944 9614 9380 -1510 4084 -3084 -3499 6851 -7316 7517 -172 1923 6690 -9334 639 -7411 55 -6105 4174 -7667 -9254 3848 -7194 9846 4137 -6914 -1023 6028 91...
output:
222431
result:
ok single line: '222431'
Test #16:
score: 0
Accepted
time: 3ms
memory: 76000kb
input:
500 -9312 3629 8352 -7728 5135 81 -959 251 -9992 -4873 6875 1153 2051 -559 7920 2726 9524 -2830 -4068 9650 -9989 3902 -4634 -4342 -6615 3225 -6581 -2189 -7899 8427 -8501 5663 -7532 -3316 -31 7085 912 7165 5484 5435 1439 9351 9059 1071 -7166 -7371 -6786 -2978 -1303 -2821 -90 827 -2934 -4066 6413 -265...
output:
334460
result:
ok single line: '334460'
Test #17:
score: 0
Accepted
time: 15ms
memory: 76016kb
input:
2990 -970733755 373162926 610706002 746420415 -24022769 446900035 80395723 -518380142 727642894 -802578839 -299221072 790023549 812359052 558846138 816832324 987432334 802786331 -460777465 821945862 -928082137 -166432503 927724630 -663110602 304682374 -219146966 -229896662 -389891025 508234675 55873...
output:
92279083496
result:
ok single line: '92279083496'
Test #18:
score: 0
Accepted
time: 16ms
memory: 76012kb
input:
2999 -500871756 570771509 -197276377 -847066915 -566097239 289678269 -16423398 -512745365 947375427 359581421 -220058506 -704742619 714443677 606538047 -443765043 798590851 -808020275 306066404 -561778738 -713774588 -970747408 610730044 -364520383 -10370313 961430924 -631087201 732038986 -358099605 ...
output:
90429110757
result:
ok single line: '90429110757'
Test #19:
score: 0
Accepted
time: 13ms
memory: 76124kb
input:
3000 213094805 -108017794 -238229780 -650750598 -802944905 -111172376 852414678 741760591 248883131 434994214 748201077 366707297 448044854 164117798 694175620 -564280780 648921182 744291754 804391782 -908186065 97203703 245670766 -854349299 276810605 399620159 -354108676 359471020 -29381171 -498575...
output:
120899458899
result:
ok single line: '120899458899'
Test #20:
score: 0
Accepted
time: 14ms
memory: 76064kb
input:
3000 168486475 198082842 421090264 611883877 457983657 429777509 609535360 22402929 991762563 218301029 963087286 466902149 242414996 424701884 150811671 280262299 61076431 522078901 74645450 442148993 654915219 166120260 161340489 536941915 829172104 370146519 622605598 472117607 758933337 49230841...
output:
1512103572038
result:
ok single line: '1512103572038'
Test #21:
score: 0
Accepted
time: 1ms
memory: 75988kb
input:
13 2 1 5 14 5 10 9 14 20 11 11 14 4
output:
120
result:
ok single line: '120'
Test #22:
score: 0
Accepted
time: 16ms
memory: 76064kb
input:
3000 -590557474 -754423105 -488261225 -456508664 -431557527 -260691112 -497223526 -364306883 -392409017 -97595563 -130511640 -356980659 -81995018 -607766326 -887472704 -3612720 -584128861 -386360742 -732463430 -318210763 -949016176 -156279605 -505067268 -289557075 -385212833 -175330337 -185270199 -2...
output:
-1489436588
result:
ok single line: '-1489436588'
Test #23:
score: 0
Accepted
time: 3ms
memory: 75976kb
input:
57 -9 -7 -23 -20 -25 -8 -4 -1 -23 -26 -25 -4 -15 -2 -24 -5 -2 -20 -14 -29 -25 -19 -20 -4 -21 -11 0 -11 -22 -26 -5 -6 -15 -28 -13 -28 -7 -1 -17 -24 -19 -8 -8 -16 -3 -1 -28 -8 -21 -9 -23 -30 -2 -1 -20 -22 -8
output:
-17
result:
ok single line: '-17'
Test #24:
score: 0
Accepted
time: 4ms
memory: 76052kb
input:
23 3 4 -1 4 2 2 1 3 1 -1 -1 3 4 4 3 -1 4 4 3 4 3 2 3
output:
53
result:
ok single line: '53'
Test #25:
score: 0
Accepted
time: 4ms
memory: 76024kb
input:
94 11 19 -10 7 -7 21 1 16 -6 23 19 -6 15 -6 17 19 24 7 8 9 21 6 0 -7 10 10 21 7 15 17 18 19 0 -7 -2 20 24 -10 14 12 3 19 19 7 7 15 5 7 3 6 -1 17 -4 22 18 -8 19 -8 -6 23 0 0 20 -5 16 19 14 -5 6 -3 5 5 13 5 17 3 16 -7 6 2 17 7 -7 23 5 5 16 24 -9 21 -8 7 15 0
output:
778
result:
ok single line: '778'
Test #26:
score: 0
Accepted
time: 7ms
memory: 76056kb
input:
989 1633 -556 161 779 1053 1088 -847 -145 -151 553 -879 -573 -843 -399 869 -319 -507 1066 127 -186 -794 580 859 -222 -253 1392 343 -401 -283 1114 803 1360 518 -322 1622 -947 876 1671 -249 -505 1665 -844 1592 1108 402 1499 788 976 -52 752 1625 587 -333 768 -571 1339 1445 803 117 -312 1660 910 1335 14...
output:
460543
result:
ok single line: '460543'
Test #27:
score: 0
Accepted
time: 8ms
memory: 76032kb
input:
1989 343 1478 4517 1835 6948 2029 4869 8527 1193 1560 7561 691 6125 9854 7350 4106 6474 3055 7520 2847 7381 1252 -950 2536 9788 6771 3241 4985 4231 3519 5154 3624 5841 2615 3074 9528 6602 7613 7573 8277 7025 1165 6716 -429 6055 5913 8721 5844 5487 6253 7746 4267 2844 1217 -535 1814 7478 258 2993 820...
output:
9125414
result:
ok single line: '9125414'
Test #28:
score: 0
Accepted
time: 11ms
memory: 76000kb
input:
2989 -240 147 26 -28 157 323 -58 395 237 316 112 -112 -45 252 269 272 210 204 160 191 177 137 -53 310 172 254 201 -138 -20 424 -84 400 -163 398 166 126 -120 149 88 317 182 229 145 405 -39 289 151 205 -44 -70 212 -234 305 390 406 -111 406 102 232 236 -242 -99 326 418 -239 425 -139 46 278 40 265 221 1...
output:
287653
result:
ok single line: '287653'
Test #29:
score: 0
Accepted
time: 17ms
memory: 76036kb
input:
2932 4522 -2818 3547 -2262 -460 1656 3019 5301 -1151 -1510 4557 2521 -2065 -2245 5902 4313 2818 5724 -2546 -2163 2515 5751 746 -4334 -3367 -3264 -818 1818 4485 4538 970 830 -82 -1320 5788 2771 2039 5104 2435 4733 674 -3322 2839 2376 -3654 228 5167 2672 4781 -487 -3968 1240 -3166 -177 -984 5497 -2055...
output:
2669984
result:
ok single line: '2669984'
Test #30:
score: 0
Accepted
time: 17ms
memory: 76060kb
input:
2993 231 49 35 171 348 356 -21 66 -6 175 -5 22 273 338 -4 292 -21 -2 285 82 346 -1 6 374 37 25 359 185 199 263 293 -16 141 174 91 -31 27 313 276 295 381 42 297 119 229 61 244 397 240 237 231 386 218 163 348 156 327 347 395 -15 13 356 106 180 355 207 115 364 394 203 -21 379 92 247 60 205 282 255 362 ...
output:
557495
result:
ok single line: '557495'
Test #31:
score: 0
Accepted
time: 4ms
memory: 76096kb
input:
34 -1 -1 -2 -1 -2 0 0 -2 0 -2 -2 0 -1 -2 0 -1 -2 -2 -2 -2 0 -1 -1 -1 -1 -2 -2 0 -2 -2 -1 -1 -1 -2
output:
-3
result:
ok single line: '-3'
Test #32:
score: 0
Accepted
time: 4ms
memory: 76052kb
input:
7 0 0 0 -1 0 0 -1
output:
-1
result:
ok single line: '-1'
Test #33:
score: 0
Accepted
time: 4ms
memory: 76052kb
input:
23 0 -2 -2 0 -2 -2 -2 -1 -2 0 -1 0 0 0 -1 -2 1 1 1 0 -2 -1 1
output:
2
result:
ok single line: '2'
Test #34:
score: 0
Accepted
time: 4ms
memory: 76048kb
input:
93 4 -11 -8 3 35 51 14 53 34 27 48 25 -6 -5 16 18 -3 -26 -27 -31 48 3 -4 -10 -15 42 -7 -24 -5 48 42 -20 13 7 13 44 -24 -15 54 -6 41 4 36 43 51 27 13 -9 48 19 -34 -10 -4 47 23 -26 -24 49 -27 20 34 38 -33 26 14 -17 23 -29 28 12 -22 23 51 53 -22 10 40 39 48 55 -14 14 0 -33 10 -10 34 16 1 11 19 3 36
output:
1159
result:
ok single line: '1159'
Test #35:
score: 0
Accepted
time: 10ms
memory: 76000kb
input:
2993 9 -31 -21 -30 9 0 -25 2 -10 -22 -34 -12 2 -13 2 -11 -2 -17 -16 5 -12 8 -7 -30 -22 9 3 -6 -23 -33 -6 -30 -16 -24 -9 -33 5 -8 -21 -24 -15 -23 -2 7 -15 -23 -20 7 -33 2 -31 -17 -28 -14 -2 -13 -15 -15 -3 -19 -18 -4 -8 -18 3 -4 -31 -32 1 -12 -23 -30 -5 -5 9 -5 -31 -11 -15 -28 6 -17 -16 -33 -28 0 -34 ...
output:
272
result:
ok single line: '272'
Test #36:
score: 0
Accepted
time: 12ms
memory: 76008kb
input:
2827 -339 -156 -95 -143 -7 -286 -154 -145 -106 -176 -202 -6 -50 -286 -282 -273 -173 -271 -44 -43 -207 -189 -323 -132 -106 21 -303 -3 -315 22 -56 -224 -51 -145 -76 -122 -194 -332 -144 -170 -163 -263 -47 -36 -163 -321 -122 -32 -263 -180 -76 -240 -160 -260 -304 -59 -59 -286 -299 -46 -112 -243 -236 -255...
output:
-198
result:
ok single line: '-198'
Test #37:
score: 0
Accepted
time: 12ms
memory: 75996kb
input:
3000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
3000000000000
result:
ok single line: '3000000000000'
Test #38:
score: 0
Accepted
time: 18ms
memory: 76068kb
input:
3000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -100000...
output:
-2000000000
result:
ok single line: '-2000000000'
Test #39:
score: 0
Accepted
time: 11ms
memory: 76056kb
input:
1000 0 1000000 -1034 -466 -1416 -200 -758 -464 -1601 -869 -1286 -925 -294 -1840 -730 -1774 -1223 -501 -1288 -1243 -1342 -1119 -556 -280 -1227 -767 -1974 -578 -1773 -1517 -1481 -401 -1460 -256 -1880 -569 -546 -751 -1058 -1286 -399 -396 -1115 -1129 -1551 -1790 -1216 -747 -1085 -238 -1861 -499 -435 -80...
output:
1
result:
ok single line: '1'
Test #40:
score: 0
Accepted
time: 1ms
memory: 76052kb
input:
1000 0 1000000 -1734 -290 -1983 -1255 -1986 -918 -14 -1028 -1102 -1569 -171 -574 -640 -1715 -1691 -1728 -1278 -1498 -919 -39 -1198 -1029 -204 -846 -1347 -895 -280 -1817 -168 -1010 -69 -1768 -286 -243 -1469 -234 -592 -268 -227 -228 -764 -1157 -332 -1872 -1160 -1803 -274 -1668 -1000 -1321 -1939 -1005 ...
output:
6925
result:
ok single line: '6925'
Test #41:
score: 0
Accepted
time: 3ms
memory: 76120kb
input:
1000 0 1000000 -1413 -1871 854 -2907 -1980 -2005 -1756 -2631 155 -673 -1696 -1237 -1488 717 -485 76 -143 -958 -2753 155 629 -79 -1091 -707 -2532 -1063 200 -172 -543 -2356 -524 235 -1327 -375 -2776 -973 -2660 -1068 -416 228 -1644 244 -2568 -1925 -2169 -2043 -1373 -1629 -2658 -2495 967 -1466 1050 -136...
output:
30000
result:
ok single line: '30000'
Test #42:
score: 0
Accepted
time: 6ms
memory: 76056kb
input:
1000 0 1000000 -369 415 907 569 -823 -2035 -2605 -2782 51 -1142 566 304 -2756 -2562 406 -86 -1183 -1552 -2962 -2507 -2121 -1099 -2191 -1152 -568 -427 -1697 -1592 703 -436 448 27 -351 -1126 -2814 -1199 250 -1013 565 -679 -72 -1784 121 -1343 1036 -717 -1240 -2159 -2713 90 854 121 -2797 98 -1194 -1380 ...
output:
21023
result:
ok single line: '21023'