编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#1153 | #1021. jwp的区间游戏 | Compile Error | 0 | 0 ms | 0 K | C++ / 552 B | zz_ylolita | 2019-06-24 23:54:59 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
int ans, last, n;
struct node {
int a, b;
} a[1000010];
int cmp(node a, node b) { return a.a < b.a || a.a == b.a && a.b < b.b; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].a, &a[i].b);
sort(a + 1, a + n + 1, cmp);
last = 0;
for (int i = 1; i <= n; i++) {
if (a[i].a > last) {
ans++;
last = a[i].b;
} else {
if (a[i].b < last)
last = a[i].b;
}
}
printf("%d\n", ans);
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:20:2: error: 'sort' was not declared in this scope
sort(a+1,a+n+1,cmp);
^~~~
/sandbox/1/a.cpp:20:2: note: suggested alternative: 'qsort'
sort(a+1,a+n+1,cmp);
^~~~
qsort
/sandbox/1/a.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
/sandbox/1/a.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a[i].a, &a[i].b);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~