이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
const int MAXN = (int) 1e7 + 5;
int x[MAXN + 1], y[MAXN + 1];
int stk[MAXN + 1], sp[MAXN + 1];
inline int getnr() {
char ch = getchar();
int ans = 0;
while(!isdigit(ch)) {
ch = getchar();
}
while(isdigit(ch)) {
ans = ans * 10 + ch - '0';
ch = getchar();
}
return ans;
}
int main() {
#ifdef HOME
ifstream cin("A.in");
ofstream cout("A.out");
#endif
int i, n;
//ios::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
n = getnr();
for(i = 1; i <= n; i++) {
x[i] = getnr();
y[i] = getnr();
}
stk[0] = -1;
int sz = 0;
for(i = 1; i <= n; i++) {
while(sz > 0 && x[i] - x[stk[sz]] <= y[i] - y[stk[sz]]) {
sz--;
}
sp[stk[sz] + 1]++;
stk[++sz] = i;
}
sz = 0, stk[0] = n + 1;
for(i = n; i >= 1; i--) {
while(sz > 0 && x[stk[sz]] - x[i] <= y[i] - y[stk[sz]]) {
sz--;
}
sp[stk[sz]]--;
stk[++sz] = i;
}
int ans = 0;
for(i = 1; i <= n; i++) {
sp[i] += sp[i - 1];
ans += (sp[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... |