QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368470#7933. Build Permutationbradythebest27WA 0ms3504kbC++23661b2024-03-27 08:30:152024-03-27 08:30:17

Judging History

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

  • [2024-03-27 08:30:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3504kb
  • [2024-03-27 08:30:15]
  • 提交

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