QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617425#7845. Fast ForwardNefelibata277AC ✓230ms183384kbC++20920b2024-10-06 15:30:292024-10-06 15:30:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-06 15:30:29]
  • 评测
  • 测评结果:AC
  • 用时:230ms
  • 内存:183384kb
  • [2024-10-06 15:30:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e6+10;

int d[N],f[N][22];

void solve(){
	int n,c,sum=0;
	cin>>n>>c;
	for (int i=1; i<=n; ++i) cin>>d[i],d[i+n]=d[i],sum+=d[i];
	if (sum<=c){
		for (int i=1; i<=n; ++i) cout<<0<<" \n"[i==n];
		return;
	}
	int l=1,r=1;
	sum=0;
	while (l<=2*n){
		while (r<=2*n && sum<c){
			sum+=d[r];
			++r;
		}
		f[l][0]=r;
		sum-=d[l];
		++l;
	}
	for (int i=0; i<=20; ++i) f[n*2+1][i]=n*2+1;
	for (int i=2*n; i; --i)
		for (int j=1; j<=20; ++j)
			f[i][j]=f[f[i][j-1]][j-1];
	for (int i=1; i<=n; ++i){
		int pos=i,Ans=0;
		for (int j=20; j>=0; --j){
			if (f[pos][j]-i<n){
				Ans+=1<<j;
				pos=f[pos][j];
			}
		}
		cout<<Ans<<" \n"[i==n];
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int _=1;
	while (_--) solve();
	return 0;
}
/*

10 5
4 1 5 5 1 3 2 1 5 2

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5684kb

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: 5628kb

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: 5604kb

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: 153ms
memory: 183348kb

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: 54ms
memory: 13372kb

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: 117ms
memory: 183312kb

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: 230ms
memory: 183320kb

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: 5592kb

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: 5644kb

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: 5932kb

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: 5872kb

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: 205ms
memory: 183384kb

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: 185ms
memory: 183324kb

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: 202ms
memory: 183340kb

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: 205ms
memory: 183336kb

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'