QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602048 | #7037. Distance | ucup-team5071# | WA | 0ms | 3848kb | C++20 | 810b | 2024-09-30 18:32:18 | 2024-09-30 18:32:20 |
Judging History
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 '