QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#85773 | #5693. 众数 | xiafan8050 | WA | 13ms | 4264kb | C++20 | 1.2kb | 2023-03-08 14:54:30 | 2023-03-08 14:54:34 |
Judging History
answer
/**
* @author: XiaFan
* @date: 2023-03-08 14:01
**/
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::vector<int> b(n);
std::iota(b.begin(), b.end(), 0);
std::sort(b.begin(), b.end(), [&](int x, int y) {
return a[x] < a[y];
});
std::vector<bool> vis(n);
std::vector<int> ssum(n);
int ans = 0, sum = 0, lastid = -1;
for (int i = n - 1, j = 0; i >= 0; i--) {
if (vis[i]) {
continue;
}
vis[i] = true;
for (; j < n; j++) {
int id = b[j];
if (a[id] > a[i]) {
sum += a[i];
a[id] -= a[i];
break;
} else {
sum += a[id];
vis[id] = true;
}
}
ssum[i] = sum;
if (lastid == -1) {
ans += (i + 1) * ssum[i];
} else {
ans += (i + 1) * (ssum[i] - ssum[lastid]);
}
lastid = i;
}
std::cout << ans << "\n";
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 13ms
memory: 4264kb
input:
99991 3 3 3 4 3 6 4 2 2 5 3 2 3 5 3 3 2 1 2 3 4 2 3 4 3 3 3 4 3 3 3 2 3 2 3 2 4 3 3 2 3 5 3 5 4 2 4 3 3 1 3 2 2 3 4 2 3 3 2 2 4 5 3 2 3 3 1 3 3 4 1 3 4 5 1 1 3 4 2 4 3 2 5 3 3 2 2 2 4 2 4 2 2 4 2 4 3 3 2 3 2 2 1 4 3 1 3 1 2 2 3 1 1 5 2 1 2 2 3 3 1 4 4 4 3 3 3 3 1 3 3 5 5 4 4 3 3 3 4 3 6 5 3 1 1 2 2 ...
output:
-516013207
result:
wrong answer 1st lines differ - expected: '4973056284288', found: '-516013207'