제출 #205115

#제출 시각아이디문제언어결과실행 시간메모리
205115quocnguyen1012Lightning Rod (NOI18_lightningrod)C++14
100 / 100
540 ms187040 KiB
#include <bits/stdc++.h>
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 x,y;
stack<pair<int,int> > chosen;
 
int main(){
	int n=readInt();
	for (int i = 0; i < n; i++) {
		x = readInt();
		y = readInt();
        if (!chosen.empty() && x-chosen.top().first<=chosen.top().second-y) continue;
        while (!chosen.empty() && x-chosen.top().first<=y-chosen.top().second){
            chosen.pop();
        }
        chosen.push(make_pair(x,y));
    }
	cout<<chosen.size();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...