이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
bool assign_min(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<typename T>
bool assign_max(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return p1.second > p2.second;
}
};
struct sum_cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return p1.first + p1.second > p2.first + p2.second;
}
};
struct sub_cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return p1.first - p1.second < p2.first - p2.second;
}
};
void solve() {
ll n;
cin >> n;
set<pair<ll, ll>, cmp> s1;
set<pair<ll, ll>, sum_cmp> s2;
set<pair<ll, ll>, sub_cmp> s3;
for (ll i = 0; i < n; i++) {
ll x, y;
cin >> x >> y;
s1.emplace(x, y);
s2.emplace(x, y);
s3.emplace(x, y);
}
ll ans = 0;
while (!s1.empty()) {
ans++;
auto[x, y] = *s1.begin();
s3.erase(*s1.begin());
s2.erase(*s1.begin());
s1.erase(s1.begin());
while (!s2.empty()) {
auto[nx, ny] = *s2.begin();
if (abs(x - nx) <= y - ny) {
s3.erase(*s2.begin());
s1.erase(*s2.begin());
s2.erase(s2.begin());
} else {
break;
}
}
while (!s3.empty()) {
auto[nx, ny] = *s3.begin();
if (abs(x - nx) <= y - ny) {
s1.erase(*s3.begin());
s2.erase(*s3.begin());
s3.erase(s3.begin());
} else {
break;
}
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
# | 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... |