QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#602048#7037. Distanceucup-team5071#WA 0ms3848kbC++20810b2024-09-30 18:32:182024-09-30 18:32:20

Judging History

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

  • [2024-09-30 18:32:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-09-30 18:32:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
int solve(){
    int n;cin>>n;
    n--;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    vector<int>sum(n+1);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    vector<int>ans{0,a[n]};
    int now=a[n];
    for(int i=2,suml=0,l=1,sumr=a[n],r=1;i<=n;i++){
        if(i%2==0){
            now+=a[l]*l-suml+sumr-a[l]*r;
            suml+=a[l];
            l++;
        }
        else{
            now+=a[n-r]*l-suml+sumr-a[n-r]*r;
            sumr+=a[n-r];
            r++;
        }
        ans.push_back(now);
    }
    for(auto it:ans)cout<<it<<" ";;cout<<"\n";
    return 0;
}
signed main(){
    int T;
    cin>>T;
    while(T--)solve();
    return 0;
}

詳細信息

Test #1:

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

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 '