QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617410#7845. Fast ForwardNefelibata277WA 1ms5724kbC++20919b2024-10-06 15:26:112024-10-06 15:26:12

Judging History

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

  • [2024-10-06 15:26:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5724kb
  • [2024-10-06 15:26:11]
  • 提交

answer

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

int d[N],f[N>>1][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=1; i<=2*n; ++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>=0 && 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;
}
/*



*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5724kb

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

input:

3 3
1 1 3

output:

0 1 1

result:

ok single line: '0 1 1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 5624kb

input:

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

output:

3 3 3 3 3 3 3 3 3 3

result:

wrong answer 1st lines differ - expected: '5 4 5 4 4 5 4 4 5 4', found: '3 3 3 3 3 3 3 3 3 3'