QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#670822#7933. Build Permutationmr_vitalikWA 0ms3500kbC++141.1kb2024-10-24 03:42:422024-10-24 03:42:42

Judging History

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

  • [2024-10-24 03:42:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-10-24 03:42:42]
  • 提交

answer

#include <iostream>
#include <vector>

int main()
{
    //std::cout << "Hello World!\n";
    int n;
    std::cin >> n;
    std::vector<std::pair<int, bool>> a(n, std::pair<int, bool>(0, true));
    std::vector<int> result;

    int sum = 0;

    for (int i = 0; i < n; ++i) {
        std::cin >> a[i].first;
        sum += a[i].first;
    }

    if ((sum * 2) % n != 0) {
        std::cout << "-1" << std::endl;
        return 0;
    }

    int generalSum = (sum * 2) / n;

    for (int i = 0; i < n; ++i) {
        int firstNum = a[i].first;
        for (int j = 0; j < n; ++j) {
            int isDone = false;
            if (a[j].second && (firstNum + a[j].first) == generalSum) {
                //result[i] = a[j].first;
                a[j].second = false;
                result.push_back(j + 1);
                //std::cout << j + 1 << ' ';
                isDone = true;
            }

            if (!isDone) {
                std::cout << "-1" << std::endl;
                return 0;
            }
        }
    }

    //for (int i = 0; i)


}

詳細信息

Test #1:

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

input:

5
4 2 5 1 3

output:

-1

result:

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