QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#465837 | #3872. Gym Badges | jdkjrejvm | Compile Error | / | / | C++98 | 1.2kb | 2024-07-07 10:49:27 | 2024-07-07 10:49:29 |
Judging History
This is the latest submission verdict.
- [2024-07-07 10:49:29]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-07 10:49:27]
- 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 constructor ‘FastScanner::FastScanner()’: answer.code:15:17: error: ‘nullptr’ was not declared in this scope 15 | cin.tie(nullptr); | ^~~~~~~ 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:29:12: note: ‘std::array’ is only available from C++11 onwards answer.code:29:27: error: template argument 1 is invalid 29 | vector<array<int, 3>> tr; | ^~ answer.code:29:27: error: template argument 2 is invalid answer.code:32:34: error: ‘tr’ was not declared in this scope; did you mean ‘tm’? 32 | for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]}); | ^~ | tm answer.code:32:47: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 32 | for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]}); | ^ answer.code:33:10: error: ‘tr’ was not declared in this scope; did you mean ‘tm’? 33 | sort(tr.begin(), tr.end()); | ^~ | tm answer.code:37:15: error: ISO C++ forbids declaration of ‘c’ with no type [-fpermissive] 37 | auto &c = tr[i - 1]; | ^ answer.code:38:19: error: invalid types ‘int[int]’ for array subscript 38 | int X1 = c[1], L1 = c[2]; | ^ answer.code:39:20: error: ‘L1’ was not declared in this scope; did you mean ‘X1’? 39 | if (sum <= L1) { | ^~ | X1