QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#514794 | #7845. Fast Forward | Umok | AC ✓ | 648ms | 412984kb | C++14 | 1.5kb | 2024-08-11 10:47:43 | 2024-08-11 10:47:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define uint unsigned long long
#define lb(x) (x & (-x))
#define endl '\n'
#define INF LONG_LONG_MAX
#define eps 1e-7
const int N = 1e6 + 5;
typedef pair<int, int> PII;
int ar[N * 2], len = 21;
int st[3 * N][25];
void solve()
{
int n, m;
cin >> n >> m;
len = log(n) / log(2) + 1;
for (int i = 1; i <= n; i++)
cin >> ar[i], ar[i + n] = ar[i];
for (int i = 1; i <= 2 * n; i++)
ar[i] += ar[i - 1];
for (int i = 0; i <= len; i++)
st[2 * n + 1][i] = 2 * n + 1;
for (int i = 1; i <= 2 * n; i++)
{
int l = i - 1, r = 2 * n;
while (l + 1 < r)
{
int mid = (l + r) >> 1;
if (ar[mid] - ar[i - 1] >= m)
r = mid;
else
l = mid;
}
st[i][0] = r + 1;
}
for (int j = 1; j <= len; j++)
for (int i = 1; i <= 2 * n; i++)
st[i][j] = st[st[i][j - 1]][j - 1];
for (int i = 1; i <= n; i++)
{
int ans = 0;
int t = i;
for (int j = len - 1; j >= 0; j--)
{
if (st[t][j] < i + n)
{
t = st[t][j];
ans += 1 << j;
}
}
cout << ans << " ";
}
}
signed main()
{
IOS;
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5784kb
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: 1ms
memory: 5876kb
input:
3 3 1 1 3
output:
0 1 1
result:
ok single line: '0 1 1 '
Test #3:
score: 0
Accepted
time: 1ms
memory: 5984kb
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: 494ms
memory: 412944kb
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 ... 21589 21589 21589 21589 21589 '
Test #5:
score: 0
Accepted
time: 453ms
memory: 412984kb
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 '
Test #6:
score: 0
Accepted
time: 495ms
memory: 410872kb
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 '
Test #7:
score: 0
Accepted
time: 648ms
memory: 412868kb
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...99 999999 999999 999999 999999 '
Test #8:
score: 0
Accepted
time: 1ms
memory: 5920kb
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: 5888kb
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 ... 30 30 30 30 30 30 30 30 30 30 '
Test #10:
score: 0
Accepted
time: 1ms
memory: 7916kb
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...57 658 657 658 657 657 658 657 '
Test #11:
score: 0
Accepted
time: 0ms
memory: 7852kb
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...96 697 696 696 696 696 696 696 '
Test #12:
score: 0
Accepted
time: 517ms
memory: 412940kb
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...10 529609 529609 529609 529610 '
Test #13:
score: 0
Accepted
time: 503ms
memory: 412868kb
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 ... 49374 49374 49374 49374 49374 '
Test #14:
score: 0
Accepted
time: 642ms
memory: 412932kb
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...84 893284 893284 893284 893284 '
Test #15:
score: 0
Accepted
time: 510ms
memory: 412924kb
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 ... 98634 98634 98634 98635 98635 '