QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#368470 | #7933. Build Permutation | bradythebest27 | WA | 0ms | 3504kb | C++23 | 661b | 2024-03-27 08:30:15 | 2024-03-27 08:30:17 |
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 (auto temp: ans){
cout<<temp<<" ";
}
cout<<endl;
} else{
cout<<-1<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3504kb
input:
5 4 2 5 1 3
output:
2 4 1 5 3
result:
wrong answer