제출 #917095

#제출 시각아이디문제언어결과실행 시간메모리
917095macneilAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
133 ms21188 KiB
//cf meowcneil; t.me/macneilbot #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <bitset> #include <iterator> #include <iomanip> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <ctime> #include <deque> #include <queue> #include <stack> #include <random> #include <cassert> using namespace std; #define int long long #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define f(a) for(int i = 0; i<a; ++i) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef string str; typedef vector<str> vestr; typedef vector<int> vei; typedef vector<vector<int>> veve; void solve() { int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; sort(all(a)); vector<bool> used(n, 1); deque<int> cur; cur.push_back(0); for (int i = 1; i < n; ++i) { while(cur.size()) { int pused = cur.back(); if (a[i].first - a[pused].first <= a[i].second - a[pused].second) { used[pused] = 0; cur.pop_back(); } else if (a[i].first - a[pused].first <= a[pused].second - a[i].second) { used[i] = 0; break; } else { cur.push_back(i); break; } } if (cur.size() == 0) cur.push_back(i); } cout << cur.size(); } signed main() { int tc = 1; #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); // cin >> tc; #else ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin >> tc; #endif for (int t = 1; t <= tc; t++) { // cout << "Case #" << t << ": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...