QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#465831 | #3872. Gym Badges | jdkjrejvm | Compile Error | / | / | C++14 | 1.2kb | 2024-07-07 10:46:58 | 2024-07-07 10:46:59 |
Judging History
This is the latest submission verdict.
- [2024-07-07 10:46:59]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-07 10:46:58]
- Submitted
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 500010;
int X[N], L[N];
class FastScanner {
public:
FastScanner() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
int nextInt() {
int x;
cin >> x;
return x;
}
};
int main() {
FastScanner f;
int n = f.nextInt();
priority_queue<int> q;
vector<array<int, 3>> tr;
for (int i = 1; i <= n; ++i) X[i] = f.nextInt();
for (int i = 1; i <= n; ++i) L[i] = f.nextInt();
for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]});
sort(tr.begin(), tr.end());
long long sum = 0, ans = 0;
for (int i = 1; i <= n; ++i) {
auto &c = tr[i - 1];
int X1 = c[1], L1 = c[2];
if (sum <= L1) {
sum += X1;
q.push(X1);
++ans;
} else {
if (!q.empty() && q.top() > X1) {
sum -= q.top();
q.pop();
sum += X1;
q.push(X1);
}
}
}
cout << ans << "\n";
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:29:12: error: ‘array’ was not declared in this scope 29 | vector<array<int, 3>> tr; | ^~~~~ answer.code:5:1: note: ‘std::array’ is defined in header ‘<array>’; did you forget to ‘#include <array>’? 4 | #include <queue> +++ |+#include <array> 5 | answer.code:29:24: error: template argument 1 is invalid 29 | vector<array<int, 3>> tr; | ^~ answer.code:29:24: error: template argument 2 is invalid answer.code:32:37: error: request for member ‘push_back’ in ‘tr’, which is of non-class type ‘int’ 32 | for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]}); | ^~~~~~~~~ answer.code:33:13: error: request for member ‘begin’ in ‘tr’, which is of non-class type ‘int’ 33 | sort(tr.begin(), tr.end()); | ^~~~~ answer.code:33:25: error: request for member ‘end’ in ‘tr’, which is of non-class type ‘int’ 33 | sort(tr.begin(), tr.end()); | ^~~ answer.code:37:21: error: invalid types ‘int[int]’ for array subscript 37 | auto &c = tr[i - 1]; | ^ answer.code:39:20: error: ‘L1’ was not declared in this scope; did you mean ‘X1’? 39 | if (sum <= L1) { | ^~ | X1