QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#670822 | #7933. Build Permutation | mr_vitalik | WA | 0ms | 3500kb | C++14 | 1.1kb | 2024-10-24 03:42:42 | 2024-10-24 03:42:42 |
Judging History
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]