QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#268579 | #7845. Fast Forward | Yarema# | AC ✓ | 553ms | 198644kb | C++14 | 1.3kb | 2023-11-28 18:36:37 | 2023-11-28 18:36:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 2'000'447;
const int LOG = 22;
int up[N][LOG];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
vector<LL> a(n);
vector<LL> pref(2 * n + 1);
FOR (i, 0, n)
{
cin >> a[i];
pref[i + 1] = a[i];
pref[n + i + 1] = a[i];
}
FOR (i, 0, 2 * n)
pref[i + 1] += pref[i];
FOR (i, 0, 2 * n + 1)
{
int to = lower_bound(ALL(pref), pref[i] + k) - pref.begin();
up[i][0] = to;
}
up[2 * n + 1][0] = 2 * n + 1;
FOR (i, 1, LOG)
{
FOR (j, 0, 2 * n + 2)
{
up[j][i] = up[up[j][i - 1]][i - 1];
}
}
FOR (i, 0, n)
{
int ans = 0;
int idx = i;
RFOR (j, LOG, 0)
{
if (up[idx][j] < i + n)
{
idx = up[idx][j];
ans += 1 << j;
}
}
if (i)
cout << ' ';
cout << ans;
}
cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
7 7 1 1 1 1 1 1 1
output:
0 0 0 0 0 0 0
result:
ok single line: '0 0 0 0 0 0 0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
3 3 1 1 3
output:
0 1 1
result:
ok single line: '0 1 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10 5 4 1 5 5 1 3 2 1 5 2
output:
5 4 5 4 4 5 4 4 5 4
result:
ok single line: '5 4 5 4 4 5 4 4 5 4'
Test #4:
score: 0
Accepted
time: 465ms
memory: 198472kb
input:
1000000 22867 553 901 645 485 940 745 166 365 357 935 102 534 812 329 56 650 100 992 528 829 755 128 190 916 245 942 132 359 367 562 636 77 62 562 404 487 545 298 71 697 784 523 957 383 332 650 636 822 245 379 792 605 239 69 723 867 925 308 511 975 808 341 341 125 940 833 810 282 567 754 893 59 618 ...
output:
21589 21589 21589 21589 21589 21589 21589 21589 21589 21590 21590 21590 21590 21590 21590 21590 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 21589 ...
result:
ok single line: '21589 21589 21589 21589 21589 ...9 21589 21589 21589 21589 21589'
Test #5:
score: 0
Accepted
time: 388ms
memory: 198544kb
input:
1000000 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
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 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #6:
score: 0
Accepted
time: 411ms
memory: 198600kb
input:
1000000 1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok single line: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
Test #7:
score: 0
Accepted
time: 553ms
memory: 198644kb
input:
1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999...
result:
ok single line: '999999 999999 999999 999999 99...999 999999 999999 999999 999999'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
10 3 8 2 4 3 6 3 3 7 9 8
output:
8 8 9 8 8 8 8 8 8 8
result:
ok single line: '8 8 9 8 8 8 8 8 8 8'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
100 8 4 4 1 1 1 3 1 2 3 3 2 3 5 2 1 3 2 1 1 1 5 2 2 4 3 5 4 2 3 3 3 3 2 5 2 2 4 1 2 5 3 4 5 3 3 1 4 5 5 1 2 4 3 1 1 2 3 1 5 5 4 2 3 5 5 1 1 5 3 4 3 4 2 1 2 3 4 1 5 1 1 3 1 5 1 4 3 4 1 2 4 3 4 2 5 4 4 1 2 4
output:
30 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 30 31 30 30 30 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 31 30 30 31 30 30 31 31 30 30 31 30 30 31 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
result:
ok single line: '30 30 30 31 30 30 30 30 30 30 ...0 30 30 30 30 30 30 30 30 30 30'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
1000 12 24 12 12 8 14 20 5 20 11 4 25 23 16 24 6 7 14 7 11 6 7 16 25 5 19 8 8 20 3 10 9 8 1 25 9 2 20 2 17 22 7 5 21 25 7 23 15 24 4 17 2 1 20 10 13 19 4 19 9 14 11 7 13 4 19 12 23 19 6 20 20 17 5 25 8 15 24 18 16 2 12 23 20 10 12 19 7 23 3 25 1 16 9 6 4 6 4 10 4 1 17 12 15 18 13 8 19 22 10 25 3 16 ...
output:
658 657 657 657 658 657 657 658 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 658 657 657 657 657 657 657 657 657 658 657 658 658 657 658 657 657 657 657 657 657 658 657 657 657 658 657 658 658 657 658 657 657 658 657 658 657 657 657 657 658 657 657 657 657 658 657 657 657 658 657 ...
result:
ok single line: '658 657 657 657 658 657 657 65...657 658 657 658 657 657 658 657'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
1000 37 44 94 6 47 73 16 60 49 73 62 97 28 21 6 70 89 33 10 49 55 8 2 72 29 4 29 91 17 94 100 36 43 83 3 22 6 1 75 50 95 49 12 53 35 95 9 3 92 84 26 77 93 60 40 96 29 19 25 9 35 41 5 6 88 36 27 95 88 22 79 14 63 24 67 72 61 51 3 59 65 50 63 12 13 73 18 14 50 51 2 7 71 10 44 79 38 84 23 100 63 58 67 ...
output:
697 696 696 697 696 696 697 696 696 696 696 696 696 696 697 696 696 696 696 696 696 697 697 696 696 696 696 696 697 696 696 697 696 696 697 697 697 697 696 696 696 696 697 696 697 696 697 697 696 696 697 696 696 696 696 696 697 696 697 696 696 696 697 697 696 696 696 696 696 697 696 697 696 697 696 ...
result:
ok single line: '697 696 696 697 696 696 697 69...696 697 696 696 696 696 696 696'
Test #12:
score: 0
Accepted
time: 505ms
memory: 198476kb
input:
1000000 65 64 91 62 47 79 84 60 12 62 43 98 90 51 55 80 11 75 92 56 95 18 34 99 3 93 48 82 75 84 86 1 21 25 22 48 76 4 13 92 72 42 65 56 29 43 56 42 5 36 27 38 73 9 5 97 12 68 79 77 82 17 66 84 35 9 28 70 4 64 36 82 91 13 72 90 7 65 70 82 87 24 8 72 57 61 68 80 44 39 43 38 9 98 75 54 34 53 25 99 91 ...
output:
529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529609 529610 529609 529609 529610 529609 529610 529610 529609 529610 529609 529610 529609 529609 529609 529609 529610 529610 529610 529609 529610 529609 529610 529610 529609 529609 529610 529609...
result:
ok single line: '529609 529609 529609 529609 52...610 529609 529609 529609 529610'
Test #13:
score: 0
Accepted
time: 460ms
memory: 198544kb
input:
1000000 990 4 89 22 24 73 63 81 78 71 99 15 16 61 5 33 5 69 87 56 57 60 4 80 76 54 64 77 31 43 63 87 3 6 54 17 13 17 35 95 44 6 15 71 4 7 41 65 43 66 79 59 45 43 27 27 84 82 49 21 71 51 15 90 32 82 30 49 62 95 53 42 27 92 97 98 28 29 22 35 75 68 43 78 26 34 13 16 28 55 22 56 96 26 60 2 16 9 65 89 48...
output:
49374 49374 49374 49374 49374 49373 49373 49373 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49373 49373 49373 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49374 49373 ...
result:
ok single line: '49374 49374 49374 49374 49374 ...4 49374 49374 49374 49374 49374'
Test #14:
score: 0
Accepted
time: 540ms
memory: 198528kb
input:
1000000 114 667 871 367 86 37 432 705 325 483 395 779 392 262 847 377 319 155 671 523 29 439 943 694 795 118 246 644 369 302 103 199 846 748 826 183 256 408 947 628 670 257 219 570 840 141 936 348 901 787 138 665 886 489 339 678 819 212 406 161 974 396 752 491 323 525 319 763 524 847 19 70 505 165 2...
output:
893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893285 893284 893284 893284 893284 893284 893284 893284 893284 893284 893285 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284 893284...
result:
ok single line: '893284 893284 893284 893284 89...284 893284 893284 893284 893284'
Test #15:
score: 0
Accepted
time: 469ms
memory: 198568kb
input:
1000000 4739 474 560 955 876 736 103 890 75 806 270 824 498 94 754 955 260 597 309 885 227 709 268 926 673 166 389 729 395 305 34 224 736 263 605 773 435 399 969 416 93 909 355 71 174 964 496 219 157 500 930 36 745 505 189 989 827 181 940 743 860 12 661 385 793 43 216 362 516 415 74 154 594 909 780 ...
output:
98635 98635 98634 98634 98634 98635 98635 98635 98635 98635 98635 98634 98634 98634 98634 98635 98635 98635 98635 98635 98634 98634 98634 98634 98635 98635 98635 98635 98635 98635 98635 98634 98634 98634 98634 98634 98635 98635 98635 98635 98635 98634 98634 98634 98634 98634 98635 98635 98635 98635 ...
result:
ok single line: '98635 98635 98634 98634 98634 ...4 98634 98634 98634 98635 98635'