Submission #888214

#TimeUsernameProblemLanguageResultExecution timeMemory
888214ace5Advertisement 2 (JOI23_ho_t2)C++17
100 / 100
677 ms38008 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int,int>> xe; set<pair<int,int>> cc; for(int i = 0;i < n;++i) { int a,b; cin >> a >> b; //cin >> xe[i].first >> xe[i].second; if(cc.find({a,b}) == cc.end()) { xe.push_back({a,b}); cc.insert({a,b}); } } sort(xe.begin(),xe.end()); int tmx = -2e9; n = xe.size(); bool x[n]; for(int i = 0;i < n;++i) x[i] = 0; for(int i = 0;i < n;++i) { if(xe[i].first + xe[i].second <= tmx) { x[i] = 1; } tmx = max(tmx,xe[i].first+xe[i].second); } int tmn = 2e9; for(int i = n-1;i >= 0;--i) { if(xe[i].first - xe[i].second >= tmn) { x[i] = 1; } tmn = min(tmn,xe[i].first - xe[i].second); } int ans = 0; for(int j = 0;j < n;++j) { ans += 1-x[j]; } cout << ans; 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...