编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80242 | #1021. jwp的区间游戏 | Compile Error | 0 | 0 ms | 0 K | C++ 17 / 578 B | BenChak | 2022-07-16 17:50:57 |
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;
bool flag[1000005];
priority_queue<int> a;
priority_queue<int> b;
long long int n, ans, p = -1, c[1000005], d;
int main() {
scanf("%lld", &n);
for (int i = 1; i <= n; ++i) {
scanf("%lld%lld", &c[i], &d);
a.push(c[i]);
b.push(d);
}
sort(c + 1, c + n + 1);
for (int i = 1; i <= n; ++i) {
if (p <= a.top && flag[i] == 0) {
for (int j = 1; j <= n; ++j) {
if (flag[j] == 0 && b.top >= c[i])
flag[j] = 1;
}
p = b.top();
ans++;
}
a.pop();
b.pop();
}
printf("%lld", ans);
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:21:11: error: invalid use of member function 'std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::const_reference = const int&]' (did you forget the '()' ?)
21 | if(p<=a.top&&flag[i]==0)
| ~~^~~
| ()
/sandbox/1/a.cpp:25:22: error: invalid use of member function 'std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::const_reference = const int&]' (did you forget the '()' ?)
25 | if(flag[j]==0&&b.top>=c[i])
| ~~^~~
| ()
/sandbox/1/a.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
/sandbox/1/a.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%lld%lld",&c[i],&d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~