Submission #200045

#TimeUsernameProblemLanguageResultExecution timeMemory
200045wilwxkLightning Rod (NOI18_lightningrod)C++14
100 / 100
850 ms229716 KiB
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int> > st;
int n;

int getn() {
	char ch = getchar_unlocked();
    int ans = 0;
    while(!isdigit(ch)) {
        ch = getchar_unlocked();
    }
    while(isdigit(ch)) {
        ans = ans * 10 + ch - '0';
        ch = getchar_unlocked();
    }
    return ans;
}

int main() {
	n = getn();
	for(int i = 1; i <= n; i++) {
		int a = getn();
		int b = getn();
		if(st.size() && a-st.back().first <= abs(b-st.back().second) && st.back().second >= b) continue; 
		while(st.size() && a-st.back().first <= abs(b-st.back().second)) st.pop_back();
		st.push_back({a, b});
	}
	printf("%d\n", int(st.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...