QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670815#7933. Build PermutationmaelysWA 0ms3600kbC++17782b2024-10-24 03:27:552024-10-24 03:27:56

Judging History

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

  • [2024-10-24 03:27:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-24 03:27:55]
  • 提交

answer

#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
using namespace std;


int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    long long int sum;
    for(int i = 0; i < n; i++){
        long long int num;
        cin>>num;
        v[i] = num;
        sum+=num;
    }
    sum = sum*2 / v.size();
    vector<int> s(n);
    bool f = false;
    for(int i = 0; i < n; i++){
        int search = sum - v[i]; 
        
        for(int j = i; j < n; j++){
            if(v[j] == search){
                s[i] = j;
                f = true;
            }
            if(!f) break;
        }

    }
    if(!f) cout<<-1;
    else{
        for (int i : s)
        {
            cout<<i << ' ';
        }
        
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

5
4 2 5 1 3

output:

0 0 0 0 4 

result:

wrong answer Integer 0 violates the range [1, 5]