Submission #1135956

#TimeUsernameProblemLanguageResultExecution timeMemory
1135956agrim_09Lightning Rod (NOI18_lightningrod)C++20
0 / 100
0 ms0 KiB
// #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define endl '\n'; #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define py cout << "YES" << endl; #define pn cout << "NO" << endl; #define pb push_back #define int long long typedef long double lld; #define double lld typedef long long ll; typedef unsigned long long ull; const ll inf = 1e18; const ll mod = 1e9+7; const int N = 2e5; vector<int>primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; // Check for queue, priorioty_queue, stack, ordered_set solutions bool cmp(pair<int,int>p,pair<int,int>q){ if(p.first!=q.first){ return p.first<q.first; } return (p.second>q.second); } signed main(){ fastio; //judge(); int n; cin >> n; vector<pair<int,int>>a(n); for(int i = 0;i<n;i++) cin >> a[i].first >> a[i].second; vector<pair<int,int>>end(n); for(int i = 0;i<n;i++){ end[i].first = a[i].first - a[i].second; end[i].second = a[i].first + a[i].second; } sort(end.begin(),end.end(),cmp); int count = 1, close = end[0].second; for(int i = 1;i<n;i++){ if(end[i].second>close){ count++; close = end[i].second; } } cout << count; }
#Verdict Execution timeMemoryGrader output
Fetching results...