Submission #1263435

#TimeUsernameProblemLanguageResultExecution timeMemory
1263435kustov_vadim_533Advertisement 2 (JOI23_ho_t2)C++20
100 / 100
101 ms8260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define len(v) (int)((v).size()) template<typename T> ostream& operator<<(ostream& out, const vector<T> &a){ for (auto& x : a){ out << x << ' '; } out << '\n'; return out; } template<typename T> istream& operator>>(istream& in, vector<T> &a){ for (size_t i = 0; i < a.size(); ++i){ in >> a[i]; } return in; } mt19937 gen; inline 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(a.begin(), a.end()); stack<pair<int, int>> st; for (pair<int, int> p : a){ while (!st.empty() && p.first - st.top().first <= p.second - st.top().second){ st.pop(); } if (st.empty() || p.first - st.top().first > st.top().second - p.second){ st.push(p); } } cout << len(st) << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.precision(60); int t = 1; // cin >> t; while (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...