Submission #200047

#TimeUsernameProblemLanguageResultExecution timeMemory
200047wilwxkLightning Rod (NOI18_lightningrod)C++14
66 / 100
2100 ms193940 KiB
#include <bits/stdc++.h> using namespace std; set<pair<int, int> > s; 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(); int x = a+b; int y = b-a; auto sit = s.lower_bound({x, y}); if(sit != s.end() && sit->second >= y) continue; if(sit != s.end() && make_pair(x, y) > (*sit)) sit = prev(s.erase(sit)); while(sit != s.begin() && prev(sit)->second <= y) sit = s.erase(prev(sit)); s.insert({x, y}); } printf("%d\n", int(s.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...