Submission #1309468

#TimeUsernameProblemLanguageResultExecution timeMemory
1309468bbldrizzyAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
117 ms14364 KiB
#include <bits/stdc++.h> #include <cmath> #include <ios> #include <iostream> #include <vector> #include <random> #include <set> #include <map> #include <random> using namespace std; using ll = long long; using P = pair<int, int>; #define f first #define s second const int MOD = 998244353; const ll inf = 4*1e18; const int mx = 5*1e5+5; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<P> v; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; v.push_back({a, b}); } sort(v.begin(), v.end()); vector<P> V; for (int i = 0; i < n; i++) { if (i == 0) { V.push_back({v[0].f, v[0].s}); } else { if ((v[i].f != v[i-1].f) || (v[i].s != v[i-1].s)) { V.push_back({v[i].f, v[i].s}); } } } // for (auto it: V) { // cout << it.f << ", " << it.s << "\n"; // } ll M = 0; vector<ll> q; for (int i = 0; i < V.size(); i++) { ll v1 = V[i].f; ll v2 = V[i].s; while (!q.empty() && q.back() >= v1-v2) { q.pop_back(); } if (v1+v2 > M) { M = v1+v2; q.push_back(v1-v2); } } cout << q.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...