This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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();
add[i] = x+y;
sub[i] = y-x;
if(i > 1)
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 = n; i >= n; i++)
{
ans+=(((i==1)||(add[i] > add[i-1]))&&((i==n)||(sub[i] > sub[i+1])));
if(i < n)
sub[i] = max(sub[i], sub[i+1]);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |