QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686974 | #8582. 점프 게임 | Yansuan_HCl | 2 | 332ms | 42184kb | C++20 | 2.7kb | 2024-10-29 16:34:11 | 2024-10-29 16:34:12 |
Judging History
answer
#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = long long;
#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
for (; !IC; GC) f |= c == '-';
for (; IC; GC) x = x * 10 + c - 48;
if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e, v) if (!(e)) { meow("AF@%d\n", __LINE__ ); exit(v); }
#define vc vector
#define eb emplace_back
#define pb push_back
const int N = 250005;
ll k;
#define mid ((l + r) >> 1)
#define ls tr[p].lc
#define rs tr[p].rc
#define arg int &p, ll l, ll r
#define L ls, l, mid
#define R rs, mid + 1, r
struct node {
ll mx, tag;
int lc, rc;
void apply(ll v) { mx += v; tag += v; }
} tr[N * 177]; int ptr;
void add(int b, int e, ll v, arg) {
if (!p) p = ++ptr;
if (b <= l && e >= r) {
tr[p].apply(v);
return;
}
if (b <= mid) add(b, e, v, L);
if (e > mid) add(b, e, v, R);
tr[p].mx = max(tr[ls].mx, tr[rs].mx) + tr[p].tag;
}
ll query(int b, int e, arg) {
if (!p) return 0;
if (b <= l && e >= r) return tr[p].mx;
ll v = -1;
if (b <= mid) v = query(b, e, L);
if (e > mid) v = max(v, query(b, e, R));
assert(v >= 0);
return v + tr[p].tag;
}
int rt;
void add(int b, int e, ll v) {
if (b <= e)
add(b, e, v, rt, 0, k - 1);
else
add(b, k - 1, v, rt, 0, k - 1),
add(0, e, v, rt, 0, k - 1);
}
ll query(int b, int e) {
if (b <= e)
return query(b, e, rt, 0, k - 1);
else
return max(
query(b, k - 1, rt, 0, k - 1),
query(0, e, rt, 0, k - 1)
);
}
void check(int x, ll v) {
ll w = query(x, x);
if (v > w)
add(x, x, v - w);
}
ll M(ll x) { return (((x) % k + k) % k); }
//void test() {
// k = 5;
// add(1, 1, 2);
// ll t = query(1, 1);
// cout << t << endl;
// exit(0);
//}
ll play_game(ll m, int n, ll _k, vc<ll> lp, vc<ll> rp) {
clog << "#" << sizeof(tr) / 1048576 << endl;
// test();
k = _k;
map<ll, int> di;
di[0] = 0;
U (i, 0, n - 1) {
ll l = lp[i], r = rp[i];
++di[l]; --di[r + 1];
}
di[m + ll(1e18)] = 0;
ll a = 0;
rt = 1; ptr = 1;
for (auto it = di.begin(), jt = next(it); jt != di.end(); it = jt, ++jt) {
ll i = it->first, j = jt->first; ll d = it->second;
ll mi = i % k, mj = j % k;
a += d;
ll w = query(mi, M(mj - 1)) + ((j - i) / k) * a;
if (mi != mj)
add(mi, M(mj - 1), ((j - i) / k + 1) * a);
add(mj, M(mi - 1), ((j - i) / k) * a);
check(mj, w);
}
ll ans = tr[rt].mx;
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 0ms
memory: 3820kb
input:
1 1 1 0 0
output:
1
result:
ok single line: '1'
Test #2:
score: 6
Accepted
time: 0ms
memory: 3924kb
input:
250000 500 1 18032 175029 101994 180534 17236 150204 19363 240816 66286 170166 40660 155563 155572 165989 36560 84766 209917 222641 67178 129065 147896 220339 181655 221539 14603 58499 52144 182663 232703 234576 101708 114632 22193 192988 71686 226463 38877 70178 13921 248563 51229 102727 109765 138...
output:
43047134
result:
ok single line: '43047134'
Test #3:
score: 6
Accepted
time: 3ms
memory: 4328kb
input:
250000 5000 1 98115 241326 12876 103121 117304 218696 116396 174228 9448 120564 30837 225165 107185 124281 85828 137912 106158 189467 29941 209692 207709 230353 146355 187817 64724 164678 104368 145949 106499 169341 30590 46690 2162 207087 70614 97313 779 200486 6666 138370 582 78745 58180 144078 58...
output:
423880930
result:
ok single line: '423880930'
Test #4:
score: 6
Accepted
time: 170ms
memory: 24504kb
input:
250000 250000 1 8800 228506 10087 37260 14874 80184 94114 152089 6811 113583 16629 76050 100831 163650 20800 54725 107410 158473 21330 178096 121807 242437 210019 228617 30570 86202 169441 183611 103542 161089 34035 215955 24336 242466 120595 160111 23111 183963 93377 115055 36812 243746 141388 2179...
output:
20836107553
result:
ok single line: '20836107553'
Test #5:
score: 6
Accepted
time: 0ms
memory: 3656kb
input:
3 5 2 0 2 0 2 1 1 1 1 1 1
output:
5
result:
ok single line: '5'
Test #6:
score: 6
Accepted
time: 0ms
memory: 3844kb
input:
100 6 50 0 99 0 70 0 10 20 30 40 50 60 70
output:
6
result:
ok single line: '6'
Test #7:
score: 6
Accepted
time: 0ms
memory: 3972kb
input:
250000 500 250000 176204 240588 178422 192741 200350 228864 10611 31982 30104 53953 85884 138540 103334 152671 70875 171575 1030 227905 46069 75425 111153 114537 14337 78805 2004 241855 107078 145330 161155 173964 135233 234237 40514 114719 78211 117900 53334 56320 157399 229765 125059 220174 104323...
output:
259
result:
ok single line: '259'
Test #8:
score: 6
Accepted
time: 2ms
memory: 3920kb
input:
250000 500 249999 163419 167010 227323 231544 6747 148619 106260 128686 152281 152431 178673 210850 178326 205961 49041 220612 35816 194213 105614 112672 40379 207523 27782 234601 68749 189368 118219 235540 166163 173035 16397 133328 23091 221881 70317 119268 38823 237586 6826 127135 76186 188480 20...
output:
249
result:
ok single line: '249'
Test #9:
score: 6
Accepted
time: 2ms
memory: 3960kb
input:
250000 500 200000 123536 208095 22801 192237 89640 207952 1493 190314 36658 194434 109288 142058 64468 134455 63232 99944 187675 213208 44725 128672 186192 208839 191648 238331 9549 204236 16554 185223 136819 174099 27885 117512 78518 240152 42428 246547 136199 193849 130309 195527 141002 157860 190...
output:
255
result:
ok single line: '255'
Test #10:
score: 6
Accepted
time: 2ms
memory: 4156kb
input:
250000 500 125000 97150 245141 18359 37807 14109 97684 101513 246263 101312 129406 92721 176379 140281 185250 95049 235575 177077 246108 152616 232113 53126 69340 124089 141620 55515 82011 109786 235437 12422 193595 30248 166870 57607 179825 9731 130445 82744 232360 146503 244777 52600 57129 951 214...
output:
395
result:
ok single line: '395'
Test #11:
score: 6
Accepted
time: 12ms
memory: 6196kb
input:
250000 5000 250000 71627 242628 105561 122356 70354 96403 197923 225795 90160 186073 38572 75199 43139 249150 29888 110247 144452 243882 75659 135492 79009 199446 50990 165885 137710 160011 52214 129804 121363 211322 217789 237535 37308 172327 33541 199561 85941 133660 14598 42494 147281 228245 3601...
output:
2491
result:
ok single line: '2491'
Test #12:
score: 6
Accepted
time: 11ms
memory: 6476kb
input:
250000 5000 249999 7263 8878 64820 236041 111512 172730 54906 244884 48520 53101 42320 136629 43938 51513 53123 165416 88598 240934 75114 226579 23441 29227 11973 67196 11127 28526 48408 128382 20498 41622 130102 175741 243163 244885 114101 161247 121405 169172 102946 247680 84962 173073 146627 2043...
output:
2564
result:
ok single line: '2564'
Test #13:
score: 6
Accepted
time: 11ms
memory: 6056kb
input:
250000 5000 200000 51664 66072 48959 96435 34890 169492 86781 215484 25559 57353 9694 65228 100790 132712 193143 245541 18816 133539 8349 155999 136016 196480 23407 184019 141790 180163 115562 157712 77832 105966 66143 137453 189463 215350 94129 228725 25171 60289 131445 170424 98494 240426 4132 399...
output:
2497
result:
ok single line: '2497'
Test #14:
score: 6
Accepted
time: 7ms
memory: 5824kb
input:
250000 5000 125000 23038 49260 22023 58481 167690 227791 61738 178456 187029 228577 93572 116406 64333 158069 14793 165402 238551 242652 5047 79698 104548 206040 16726 149100 96168 150571 161386 236224 230973 237774 28036 162383 135854 186683 63012 198599 146070 231369 81288 209694 118670 144952 474...
output:
3817
result:
ok single line: '3817'
Test #15:
score: 6
Accepted
time: 332ms
memory: 35568kb
input:
250000 250000 250000 60620 110173 65040 246046 72558 74815 127517 226469 79477 141735 128460 168084 190600 232286 65560 238023 44001 130839 163358 181710 119132 169239 84170 146100 217709 239539 17393 145138 19894 91773 157441 172001 186670 197815 225491 239190 36218 57264 15714 182492 34715 231855 ...
output:
124745
result:
ok single line: '124745'
Test #16:
score: 6
Accepted
time: 322ms
memory: 35484kb
input:
250000 250000 249999 14320 109938 179359 219442 56051 244571 162 223166 21143 168950 49266 200770 66092 84913 91215 216188 127721 238388 92189 226412 131169 178676 126841 177156 145335 187778 22986 189328 12069 220235 20462 103938 53057 131995 137853 184804 98321 220470 119523 215514 3021 226212 988...
output:
125137
result:
ok single line: '125137'
Test #17:
score: 6
Accepted
time: 323ms
memory: 33572kb
input:
250000 250000 200000 33760 94993 6740 10698 53668 53904 85694 115759 50067 185295 131978 150789 13407 188196 17091 227357 29304 81008 92548 165362 227543 244278 73411 145768 1062 149065 74815 197129 169917 237325 107297 121576 105953 197614 104138 244490 86889 209437 95594 194811 106592 222401 12141...
output:
125132
result:
ok single line: '125132'
Test #18:
score: 6
Accepted
time: 318ms
memory: 30416kb
input:
250000 250000 125000 155365 230141 71664 145795 142765 181943 65291 80464 178779 243970 215443 231707 19233 197437 12196 65435 220648 243173 81764 176788 87880 160130 22759 49190 21220 34822 133308 235294 75648 94480 34312 131370 38729 86599 6283 244932 222140 238784 42139 171595 149845 214163 79181...
output:
187548
result:
ok single line: '187548'
Test #19:
score: 6
Accepted
time: 0ms
memory: 3780kb
input:
250 8 50 0 200 40 140 49 49 50 150 100 190 149 199 199 199 75 249
output:
17
result:
ok single line: '17'
Test #20:
score: 6
Accepted
time: 2ms
memory: 3872kb
input:
250000 500 124999 202167 239352 145385 187212 127053 154487 80970 104309 138238 218833 101431 140899 57206 194492 82251 121831 79777 234877 77928 133230 89304 166621 191615 243921 28689 91204 36161 150495 15876 139089 64428 72070 193471 243745 27069 118471 187721 236132 87779 235327 133035 219325 16...
output:
378
result:
ok single line: '378'
Test #21:
score: 6
Accepted
time: 2ms
memory: 3968kb
input:
250000 500 80000 31169 80004 213897 223686 47854 53407 18822 204877 130674 212333 88127 118299 33431 130873 72876 146241 146009 152052 75491 171304 77460 104773 14068 115131 79714 243294 19491 104389 11293 45595 143313 161164 22966 220518 82140 99925 51026 91822 174072 234865 122934 139387 154536 18...
output:
561
result:
ok single line: '561'
Test #22:
score: 6
Accepted
time: 2ms
memory: 3876kb
input:
250000 500 50000 18694 218026 2905 104864 166883 194819 81792 224197 176732 181963 37122 197374 121489 147220 124571 237780 50216 248769 10908 210565 151063 190781 16447 157083 29671 228523 94419 200132 84784 123472 123573 237865 4575 212124 132927 145501 54340 160781 18487 191887 50426 161525 49524...
output:
896
result:
ok single line: '896'
Test #23:
score: 6
Accepted
time: 11ms
memory: 6096kb
input:
250000 5000 124999 20072 192376 10963 131847 73194 83026 24876 158789 41441 175375 35863 207040 51738 134658 3956 98779 109445 128883 37135 150695 91822 103350 47311 176275 151687 231043 33039 231518 69700 211172 71985 129675 29661 230697 22683 100704 215895 232127 50594 92892 88251 187157 91185 169...
output:
3732
result:
ok single line: '3732'
Test #24:
score: 6
Accepted
time: 11ms
memory: 5840kb
input:
250000 5000 80000 58445 58514 73588 155199 19190 237584 15021 162061 35587 208042 67347 82938 33520 66905 94077 243548 195993 205248 75063 135194 186766 241449 81432 249529 44646 189754 88533 209397 65768 95668 203551 212985 69509 200644 164292 244507 8032 90528 95921 181272 66270 69585 147614 23028...
output:
5410
result:
ok single line: '5410'
Test #25:
score: 6
Accepted
time: 10ms
memory: 5676kb
input:
250000 5000 50000 147922 234945 21624 140865 106643 119709 65334 92686 63183 249259 207994 239187 34137 59757 217035 234086 18811 247852 9431 44749 2312 212491 754 81472 21009 151931 31913 210230 45791 232667 49762 143942 161988 163751 131071 152579 161346 243080 151225 235662 36507 100316 72962 107...
output:
8484
result:
ok single line: '8484'
Test #26:
score: 6
Accepted
time: 302ms
memory: 30200kb
input:
250000 250000 124999 2677 247927 138954 176621 48093 160975 31941 70764 14697 67489 67922 197029 206137 223917 78557 172748 224255 232123 180464 189779 139566 213491 95564 116734 102813 121816 43784 62815 39827 176929 19447 168743 6999 223343 8998 232118 46834 159161 161331 204990 34628 84036 53464 ...
output:
187734
result:
ok single line: '187734'
Test #27:
score: 6
Accepted
time: 295ms
memory: 28484kb
input:
250000 250000 80000 96974 155381 66922 180127 199833 214041 3309 41042 98132 110413 177414 219757 15495 148058 67155 133626 3716 100008 29721 223138 83361 216709 6250 155592 15544 51215 63423 181443 93375 173268 168019 176606 106991 196501 104870 156550 13980 211375 8047 181803 142157 168375 116442 ...
output:
272854
result:
ok single line: '272854'
Test #28:
score: 6
Accepted
time: 293ms
memory: 26976kb
input:
250000 250000 50000 94789 175611 35445 112826 44813 81011 29121 150274 237328 247123 93705 238342 64546 227133 206252 214787 7854 170918 36277 94641 152125 229387 8629 143371 1172 90200 105646 166672 68151 221823 188939 248499 119598 175735 70668 219911 52889 123735 187862 215425 20902 159971 11774 ...
output:
425032
result:
ok single line: '425032'
Test #29:
score: 6
Accepted
time: 0ms
memory: 3656kb
input:
250 8 49 0 200 40 140 49 49 50 150 100 190 149 199 199 199 75 249
output:
19
result:
ok single line: '19'
Test #30:
score: 6
Accepted
time: 0ms
memory: 4168kb
input:
250000 500 49999 4856 88090 139361 228192 240059 244612 47502 191290 112927 127924 178802 182492 105595 220475 100898 116876 64153 212289 138445 155491 326 187713 55090 209500 51706 144390 3587 30604 42831 186525 113819 242213 234615 249736 107104 127430 62111 124209 3762 229069 112276 208717 95429 ...
output:
851
result:
ok single line: '851'
Test #31:
score: 6
Accepted
time: 1ms
memory: 3776kb
input:
250000 500 10000 214880 236399 19044 114605 49616 171832 113563 173539 213805 224646 57927 221634 97055 123005 200467 207828 11650 227418 22121 186119 145754 169541 22333 143818 112432 139053 158301 215017 211519 228499 143480 213736 29309 203769 18275 86874 20365 201897 49623 114619 23094 142740 87...
output:
4304
result:
ok single line: '4304'
Test #32:
score: 6
Accepted
time: 0ms
memory: 4068kb
input:
250000 500 9999 196493 232984 157804 162234 5426 103536 14063 246449 37693 158374 69289 80016 112920 173222 46043 167040 105978 130954 54368 86857 22267 128013 98932 202488 73617 82185 27759 108008 72315 158294 7143 177374 126785 249785 18069 75169 30671 201996 130297 156254 6575 32004 110412 204893...
output:
4205
result:
ok single line: '4205'
Test #33:
score: 6
Accepted
time: 1ms
memory: 3944kb
input:
250000 500 500 61864 236241 66529 100680 94892 233136 10323 185845 9152 66013 80027 224568 199286 245110 31336 165225 123538 129936 130976 141995 81153 104381 25577 226847 3416 15939 21853 221798 28791 76159 8357 64730 19666 23702 78583 193717 70903 97900 80946 214280 136487 249078 149022 208747 335...
output:
85305
result:
ok single line: '85305'
Test #34:
score: 6
Accepted
time: 1ms
memory: 3652kb
input:
250000 500 499 100413 222362 30474 48086 71462 147287 193528 222150 25352 152182 145078 181561 21371 100600 22435 234926 77064 178502 41594 244078 38315 173597 35702 223691 101061 116525 129909 166573 29528 193613 131696 187560 124827 190329 47065 169631 12972 189480 63854 102657 142923 176736 65398...
output:
83839
result:
ok single line: '83839'
Test #35:
score: 0
Wrong Answer
time: 1ms
memory: 3708kb
input:
250000 500 100 37057 96123 31658 203038 42863 55695 43593 111382 24436 59778 351 149923 194605 196546 60015 225040 137456 205949 175131 242372 92057 174837 144798 181396 92303 127255 55021 220756 9269 166522 92503 169220 126389 180747 62063 190987 8116 9761 5614 109311 32003 215965 149005 235968 519...
output:
418401
result:
wrong answer 1st lines differ - expected: '417259', found: '418401'
Subtask #2:
score: 2
Accepted
Test #48:
score: 2
Accepted
time: 0ms
memory: 3556kb
input:
1000000000000 2 1 0 999999999999 0 999999999999
output:
2000000000000
result:
ok single line: '2000000000000'
Test #49:
score: 2
Accepted
time: 0ms
memory: 3700kb
input:
1000000000000 500 1 527513625833 530840786800 647452909306 949600639479 31806145281 650067061607 553077890363 630839559971 257074666199 821047850133 40471877454 201059651806 803554707022 898136081520 471301438903 727946340638 264120737467 760504330624 907943458863 964032452524 429831669748 436619668...
output:
170256829357459
result:
ok single line: '170256829357459'
Test #50:
score: 2
Accepted
time: 1ms
memory: 3912kb
input:
1000000000000 500 1 414 999999999862 339 999999999592 110 999999999609 65 999999999687 201 999999999683 476 999999999660 27 999999999601 99 999999999861 154 999999999840 381 999999999680 418 999999999766 467 999999999594 328 999999999839 324 999999999876 228 999999999732 12 999999999519 151 99999999...
output:
499999999756043
result:
ok single line: '499999999756043'
Test #51:
score: 2
Accepted
time: 0ms
memory: 3868kb
input:
1000000000000 500 1 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 99999999...
output:
500000000000000
result:
ok single line: '500000000000000'
Test #52:
score: 2
Accepted
time: 3ms
memory: 4568kb
input:
1000000000000 5000 1 221556197091 291816057384 148769055147 275292703709 534309543008 824106987357 78364289194 141984928287 250487454460 735122717003 738050503381 855545135847 369599220819 764293495846 400040673548 588081233660 518776974 861872533120 131602584518 813182000883 35688052931 65622312854...
output:
1660567231836695
result:
ok single line: '1660567231836695'
Test #53:
score: 2
Accepted
time: 3ms
memory: 4340kb
input:
1000000000000 5000 1 684 999999997778 1255 999999995923 186 999999996399 1894 999999999460 3812 999999997356 1756 999999998768 354 999999996804 2652 999999998655 2504 999999996983 4708 999999995686 2398 999999998054 1085 999999998326 728 999999996050 3622 999999997692 1535 999999999997 4353 99999999...
output:
4999999974797344
result:
ok single line: '4999999974797344'
Test #54:
score: 2
Accepted
time: 1ms
memory: 3716kb
input:
1000000000000 5000 1 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 9999999...
output:
5000000000000000
result:
ok single line: '5000000000000000'
Test #55:
score: 2
Accepted
time: 243ms
memory: 42184kb
input:
1000000000000 250000 1 236177530578 673136242266 248319786421 549057238550 459752478411 572309112542 226890967260 458031457160 151110476596 639062902378 324653264944 627910197907 14880272367 315630033255 240100010106 955415705404 168489956211 508526888692 89621094054 319031766833 688000331282 716851...
output:
83326370007046216
result:
ok single line: '83326370007046216'
Test #56:
score: 2
Accepted
time: 214ms
memory: 30860kb
input:
1000000000000 250000 1 68879 999999808782 76483 999999803402 205232 999999849112 223445 999999891538 56925 999999790929 111672 999999870842 147863 999999752623 113911 999999999025 52704 999999986166 129439 999999796783 172785 999999771286 92737 999999850681 95029 999999829161 169669 999999985298 851...
output:
249999937551812170
result:
ok single line: '249999937551812170'
Test #57:
score: 2
Accepted
time: 20ms
memory: 11100kb
input:
1000000000000 250000 1 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 999999999999 0 99999...
output:
250000000000000000
result:
ok single line: '250000000000000000'
Subtask #3:
score: 0
Memory Limit Exceeded
Test #58:
score: 0
Memory Limit Exceeded
input:
1000000000000 500 700000000000 489537143769 630143286953 260425914571 671352459669 442325411396 997637458393 437240212342 479801508680 171199409565 885024134315 335757811617 912510646664 255044472489 455548540270 529689058580 898532986737 266612500614 411414634748 267273797534 728080538500 289244868...
output:
Unauthorized output
result:
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Memory Limit Exceeded
Test #79:
score: 0
Memory Limit Exceeded
input:
1000000000000 500 199999999999 706819024629 963292506311 230674270029 335986697877 629242014470 656530582138 169121845078 356297897421 427332409502 950785188805 136568479540 890773747341 128873878004 517715625255 592265122313 992654704254 159253384693 445902398415 851956611956 861825483439 160403414...
output:
Unauthorized output
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%