QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368472#7933. Build Permutationbradythebest27WA 113ms14948kbC++23815b2024-03-27 08:42:372024-03-27 08:42:38

Judging History

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

  • [2024-03-27 08:42:38]
  • 评测
  • 测评结果:WA
  • 用时:113ms
  • 内存:14948kb
  • [2024-03-27 08:42:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    double sum = 0;
    int x;
    vector<int> nums;
    map<int, int> myMap;
    int c = 0;
    while (t--){
        c++;
        cin>>x;
        nums.push_back(x);
        myMap.insert(pair<int,int>(x,c));
        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<<myMap[ans[i]]<<" ";
        }
        cout<<myMap[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: 100
Accepted
time: 1ms
memory: 3552kb

input:

5
4 2 5 1 3

output:

2 1 4 3 5

result:

ok 

Test #2:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

3
2 2 3

output:

-1

result:

ok 

Test #3:

score: 0
Accepted
time: 113ms
memory: 13332kb

input:

199528
581552649 419782901 924554494 589802859 878336763 659984178 419820729 521791999 956262027 523946290 442086405 808419260 875183942 860794919 584899704 494193909 687014591 794119827 641706288 734029639 795387770 803653459 889799156 455122734 655375888 757642629 427654115 987811208 593072829 584...

output:

-1

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 109ms
memory: 14948kb

input:

199680
774760412 315033238 665140012 402128528 221827348 923752357 281703052 551555739 483983889 622621809 949928382 909484599 413397988 424613137 353323926 392255354 551928848 464853065 860603765 618364501 423106762 752293338 551415838 898671881 969815739 150102831 644806419 333507443 379455235 981...

output:

-1

result:

wrong answer Integer -1 violates the range [1, 199680]