제출 #878480

#제출 시각아이디문제언어결과실행 시간메모리
878480phoenix0423Advertisement 2 (JOI23_ho_t2)C++17
100 / 100
450 ms39396 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(x) (x).begin(), (x).end() #define pb push_back #define eb emplace_back #define f first #define s second const int maxn = 2e5 + 5; int main(void){ fastio; int n; cin>>n; vector<pll> a; map<int, int> mp; for(int i = 0; i < n; i++){ int x, y; cin>>x>>y; mp[x] = max(mp[x], y); } for(auto [x, y] : mp) a.eb(x, y); n = a.size(); vector<int> cov(n, 1); int mx = a[0].s; for(int i = 1; i < n; i++){ mx -= a[i].f - a[i - 1].f; if(mx >= a[i].s) cov[i] = 0; else mx = a[i].s; } mx = a[n - 1].s; for(int i = n - 2; i >= 0; i--){ mx -= a[i + 1].f - a[i].f; if(mx >= a[i].s) cov[i] = 0; else mx = a[i].s; } cout<<accumulate(ALL(cov), 0)<<"\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...