제출 #924629

#제출 시각아이디문제언어결과실행 시간메모리
924629esomerAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
181 ms33204 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; vector<pair<int, int>> v(N); for(int i = 0; i < N; i++){ cin >> v[i].first >> v[i].second; } sort(v.begin(), v.end()); int useless = 0; set<pair<int, int>> left; int mxVal = -2e9; for(int i = 0; i < N; i++){ int val1 = v[i].second - v[i].first; int val2 = v[i].first + v[i].second; if(mxVal >= val2){ useless++; continue; } mxVal = val2; while(!left.empty() && (*left.begin()).first <= val1){ useless++; left.erase(left.begin()); } left.insert({val1, i}); } cout << N - useless << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...