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>
#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;
}
# | 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... |