제출 #988185

#제출 시각아이디문제언어결과실행 시간메모리
988185dubabubaAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
141 ms26820 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define ff first #define ss second #define MP make_pair const int LOG = 22; const int mxn = 1e6 + 3; const int mod = 1e9 + 7; int x[mxn], e[mxn], n; int d[mxn], s[mxn]; void solve() { cin >> n; vector<int> id; for(int i = 1; i <= n; i++) { cin >> x[i] >> e[i]; d[i] = e[i] - x[i]; s[i] = e[i] + x[i]; id.push_back(i); } sort(id.begin(), id.end(), [&](int i, int j) { if(d[i] != d[j]) return d[i] > d[j]; return s[i] > s[j]; }); int en = 0, ans = 0; for(int i : id) { if(s[i] > en) { ans++; en = s[i]; } } cout << ans << endl; } signed main() { #ifdef LOCAL auto start = chrono::high_resolution_clock::now(); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); signed t = 1; // cin >> t; while(t--) solve(); #ifdef LOCAL auto end = chrono::high_resolution_clock::now(); cout << "\n"; for(int i = 0; i <= 20; ++i) cout << '-'; cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl; #endif 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...