QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368471#7933. Build Permutationbradythebest27WA 1ms3472kbC++23702b2024-03-27 08:31:542024-03-27 08:31:56

Judging History

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

  • [2024-03-27 08:31:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3472kb
  • [2024-03-27 08:31:54]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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