Submission #769535

#TimeUsernameProblemLanguageResultExecution timeMemory
769535OzyAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
253 ms44640 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) { //debugsl(act.x); //debug(act.e); 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; //debugsl("right"); //debugsl((*it).xx); //debug((*it).ee); //debugsl(a); //debug(b); if (a <= b) inserto = false; } if (it != advertisors.begin()) { it--; a = act.x - (*it).xx; b = (*it).ee - act.e; //debugsl("left"); //debugsl((*it).xx); //debug((*it).ee); //debugsl(a); //debug(b); if (a <= b) inserto = false; } } if (inserto) { //debug("SI"); 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...