제출 #922316

#제출 시각아이디문제언어결과실행 시간메모리
922316Shayan86Advertisement 2 (JOI23_ho_t2)C++14
100 / 100
156 ms45228 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define Mp make_pair #define sep ' ' #define endl '\n' #define F first #define S second #define pb push_back #define all(x) (x).begin(),(x).end() #define kill(res) cout << res << '\n', exit(0); #define set_dec(x) cout << fixed << setprecision(x); #define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll N = 5e5 + 50; const ll Mod = 1e9 + 7; ll n, m; vector<pll> vec; vector<ll> daste[N]; int main(){ fast_io; cin >> n; for(int i = 1; i <= n; i++){ int x, y; cin >> x >> y; vec.pb({x+y, y-x}); } sort(all(vec), greater<pll>()); int cur = 1; for(int i = 0; i < n; i++){ if(i == 0 || vec[i].F == vec[i-1].F){ daste[cur].pb(vec[i].S); } else{ cur++; daste[cur].pb(vec[i].S); } } ll cnt = 0, mx = -Mod; for(int i = 1; i <= cur; i++){ sort(all(daste[i]), greater<ll>()); cnt++; if(mx >= daste[i][0]) cnt--; mx = max(mx, daste[i][0]); } cout << cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...