#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
inline int readInt() {
int x = 0;
char ch = getchar_unlocked();
while (ch < '0' || ch > '9') ch = getchar_unlocked();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
int MinPyramids(int N, vector<int>X, vector<int>Y) {
int ms=-20;int n=N;
vector<int>v(N,1);
for(int i=0;n>i;++i)if(X[i]+Y[i]>ms)ms=X[i]+Y[i];else v[i]=0;
ms=-2e9;
for(int i=n-1;i>=0;--i)if(-X[i]+Y[i]>ms)ms=-X[i]+Y[i];else v[i]=0;
int t=0;
for(int i=0;n>i;++i)t+=v[i];
return t;
}
int main(){
int N = readInt();
vector <int> X(N);
vector <int> Y(N);
for(int i = 0; i < N; i++) {
X[i] = readInt();
Y[i] = readInt();
}
int ans= MinPyramids(N,X,Y);
printf("%d", ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
191684 KB |
Output is correct |
2 |
Correct |
318 ms |
240608 KB |
Output is correct |
3 |
Correct |
288 ms |
234144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
320 KB |
Output is correct |
14 |
Correct |
12 ms |
7492 KB |
Output is correct |
15 |
Correct |
12 ms |
7440 KB |
Output is correct |
16 |
Correct |
10 ms |
6584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
294 ms |
196572 KB |
Output is correct |
2 |
Correct |
330 ms |
262144 KB |
Output is correct |
3 |
Correct |
327 ms |
262144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
191684 KB |
Output is correct |
2 |
Correct |
318 ms |
240608 KB |
Output is correct |
3 |
Correct |
288 ms |
234144 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
308 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
320 KB |
Output is correct |
17 |
Correct |
12 ms |
7492 KB |
Output is correct |
18 |
Correct |
12 ms |
7440 KB |
Output is correct |
19 |
Correct |
10 ms |
6584 KB |
Output is correct |
20 |
Correct |
294 ms |
196572 KB |
Output is correct |
21 |
Correct |
330 ms |
262144 KB |
Output is correct |
22 |
Correct |
327 ms |
262144 KB |
Output is correct |
23 |
Correct |
565 ms |
262144 KB |
Output is correct |
24 |
Correct |
493 ms |
262144 KB |
Output is correct |
25 |
Correct |
462 ms |
262144 KB |
Output is correct |