#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int n;
signed main() {
ioss;
cin >> n;
int x[n+2] = {}, y[n+2] = {};
if(n == 2) {
cin >> x[1] >> y[1] >> x[2] >> y[2];
if(abs(x[1]-x[2]) <= y[1]-y[2] || abs(x[1]-x[2]) <= y[2]-y[1]) cout << 1 << endl;
else cout << 2 << endl;
return 0;
}
bool one = 1, diff = 0;
for(int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
if(y[i] != 1) one = 0;
if(x[i] != i) diff = 1;
}
if(one) {
int ans = 1;
for(int i = 2; i <= n; i++) {
if(x[i] != x[i-1]) ans++;
}
cout << ans << endl;
return 0;
}
if(!diff) {
int ans = 0;
for(int i = 1; i <= n; i++) {
if(i == n) {
if(y[i-1] <= y[i]) ans++;
}
else {
if(y[i] > y[i+1]) ans++, i++;
else if(y[i] == y[i+1]) ans++;
}
}
cout << ans << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1165 ms |
164804 KB |
Output is correct |
2 |
Correct |
1220 ms |
171328 KB |
Output is correct |
3 |
Correct |
1097 ms |
166908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1196 ms |
164248 KB |
Output is correct |
2 |
Correct |
1107 ms |
173000 KB |
Output is correct |
3 |
Correct |
1102 ms |
168684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1165 ms |
164804 KB |
Output is correct |
2 |
Correct |
1220 ms |
171328 KB |
Output is correct |
3 |
Correct |
1097 ms |
166908 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |