QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368471 | #7933. Build Permutation | bradythebest27 | WA | 1ms | 3472kb | C++23 | 702b | 2024-03-27 08:31:54 | 2024-03-27 08:31:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
double sum = 0;
int x;
vector<int> nums;
while (t--){
cin>>x;
nums.push_back(x);
sum+=x;
}
double av = (sum+sum)/nums.size();
if (av != (int) av){
cout<<-1<<endl;
return 0;
}
vector<int> ans;
int newSum = 0;
for (int curr: nums){
ans.push_back(av-curr);
newSum+=av-curr;
}
if (newSum == sum){
for (int i = 0; i < ans.size() - 1; i++){
cout<<ans[i]<<" ";
}
cout<<ans[ans.size()-1]<<endl;
} else{
cout<<-1<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3472kb
input:
5 4 2 5 1 3
output:
2 4 1 5 3
result:
wrong answer