QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217285#7037. DistancezzzyzzzWA 0ms3512kbC++17683b2023-10-16 18:10:252023-10-16 18:10:25

Judging History

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

  • [2023-10-16 18:10:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3512kb
  • [2023-10-16 18:10:25]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int w[100010];
int idx[100010];

int main() {
	int T;
	cin>>T;
	
	while(T--) {
		int n;
		cin>>n;
		
		for(int i=1;i<n;i++) cin>>w[i];
		
		idx[1]=0;
		for(int i=2;i<=n;i++) idx[i]=idx[i-1]+w[i-1];

		ll res=0;
		ll suma=0,sumb=0;
		int cnta=0,cntb=0;
		int l=1,r=n;
		for(int i=1;i<=n;i++) {
			if(i%2==1) {
				res+=(ll)cnta*idx[l]-suma+sumb-(ll)cntb*idx[l];
				suma+=idx[l];
				l++;
				cnta++;
			}else {
				res+=(ll)cnta*idx[r]-suma+sumb-(ll)cntb*idx[r];
				sumb+=idx[r];
				r--;
				cntb++;
			}
			
			printf("%lld ",res);
		}
		printf("\n");
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3512kb

input:

1
5
2 3 1 4

output:

0 10 20 34 48 

result:

wrong answer 1st lines differ - expected: '0 10 20 34 48', found: '0 10 20 34 48 '