Submission #769526

#TimeUsernameProblemLanguageResultExecution timeMemory
769526OzyAdvertisement 2 (JOI23_ho_t2)C++17
0 / 100
1 ms320 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define lli long long int #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> //para el orden #define e first #define x second //para el set #define ee second #define xx first vector<pll> orden; lli n,a,b,res; set<pll> advertisors; bool inserto; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; rep(i,1,n) { cin >> a >> b; orden.push_back({b,a}); } sort(orden.begin(), orden.end()); reverse(orden.begin(), orden.end()); for(auto act : orden) { inserto = true; if (advertisors.empty()) inserto = true; else { auto it = advertisors.lower_bound({act.x,0}); if (it != advertisors.end()) { a = (*it).xx - act.x; b = (*it).ee - act.e; //debug("right"); //debugsl(a); //debug(b); if (a > b) inserto = false; } if (it != advertisors.begin()) { it--; a = act.x - (*it).xx; b = (*it).ee - act.e; if (a > b) inserto = false; } } if (inserto) { res++; advertisors.insert({act.x, act.e}); } } cout << res; 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...