Submission #787296

#TimeUsernameProblemLanguageResultExecution timeMemory
787296ddeadeyeAdvertisement 2 (JOI23_ho_t2)C++17
10 / 100
126 ms24700 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define si second #define ar array #define pb push_back typedef pair<ll,ll> pi; typedef tuple<int,int,int> ti; typedef vector<int> vi; template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;} template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;} void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) int n; vector<pi> rr; stack<pi> st; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin.exceptions(ios::badbit|ios::failbit); cin >> n; for (int i = 1; i <= n; ++i) { int x,e; cin >> x >> e; rr.pb({x-e, x+e}); } sort(rr.begin(), rr.end(), [](pi a, pi b) { if (a.si == b.si) return a.fi < b.fi; return a.si < b.si; }); for (auto [s, e]: rr) { while (st.size() && st.top().fi >= s) st.pop(); st.push({s, e}); } cout << (int)st.size(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...