Submission #137682

#TimeUsernameProblemLanguageResultExecution timeMemory
137682ekremLightning Rod (NOI18_lightningrod)C++17
80 / 100
2032 ms79972 KiB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define coc g[mode][i]
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)>>1)
#define mod 1000000007
#define inf 1000000009
#define N 5000005

using namespace std;

typedef long long ll;
typedef pair < int , int > ii;
typedef pair < double , double > dd;

int n, m, result;
char ch;
ii a;
stack < ii > s;

int readInt () {
	result = 0;
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	return result;
}

int main(){
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	n = readInt();
	for(int i = 1; i <= n; i++){
		// scanf("%d %d",&a.st ,&a.nd);
		a.st = readInt();
		a.nd = readInt();
		while(!s.empty() and abs(s.top().st - a.st) <= a.nd - s.top().nd)
			s.pop();
		if(!s.empty() and abs(s.top().st - a.st) <= s.top().nd - a.nd)
			continue;
		s.push(a);
	}
	printf("%d\n", (int)s.size());
	return 0;
}
#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...