이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |