제출 #1166253

#제출 시각아이디문제언어결과실행 시간메모리
1166253akacool445kAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
110 ms8264 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define int long long #define pint pair<int, int> #define vint vector<int> const int mod = 1e9 + 7; const int shrek = 5e5 + 5; const int say = INT_MAX / 2; const int gex = INT_MIN / 2; const long long oo = 1e18; bool cmp(pint a, pint b) { if((a.ss - a.ff) == (b.ss - b.ff)) { return a.ff > b.ff; } return (a.ss - a.ff) > (b.ss - b.ff); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; pint a[n]; for(int i = 0; i < n; i++) { cin >> a[i].ff >> a[i].ss; } sort(a, a + n, cmp); int maxi = a[0].ss + a[0].ff; int ans = 1; for(int i = 1; i < n; i++) { if((a[i].ss - a[i].ff) != (a[i - 1].ss - a[i - 1].ff)) { if(maxi < (a[i].ss + a[i].ff)) { ans++; } } maxi = max(maxi, a[i].ss + a[i].ff); } cout << ans << '\n'; 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...