#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
inline int readInt()
{
int x = 0; char ch=getchar_unlocked(); bool st = 1;
while(ch < '0' || ch > '9'){if(ch=='-')st=0; ch=getchar_unlocked();}
while(ch>='0'&&ch<='9'){x = (x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
return st?x:-x;
}
vector<int> add(1e7+1, 0);
vector<int> sub(1e7+1, 0);
signed main()
{
fast();
int n = readInt();
for(int i = 1; i <= n; i++)
{
int x, y;
x = readInt();
y = readInt();
sub[i] = x+y;
add[i] = y-x;
}
for(int i = 2; i <= n; i++)
add[i] = max(add[i], add[i-1]);
for(int i = n-1; i >= 1; i--)
sub[i] = max(sub[i], sub[i+1]);
int ans = 0;
for(int i = 1; i <= n; i++)
ans+=(((i==1)||(add[i] > add[i+1]))&&((i==n)||(sub[i] > sub[i+1])));
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
340 ms |
165644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
156760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
156760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
156760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
156760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
331 ms |
156872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
340 ms |
165644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |