# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1157648 | fryingduc | Advertisement 2 (JOI23_ho_t2) | C++20 | 114 ms | 6308 KiB |
#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int maxn = 5e5 + 5;
int n, ord[maxn];
pair<int, int> a[maxn];
void solve() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].first >> a[i].second;
ord[i] = i;
}
sort(ord + 1, ord + n + 1, [](const int &x, const int &y) -> bool {
if (a[x].first + a[x].second == a[y].first + a[y].second) {
return a[x].second - a[x].first < a[y].second - a[y].first;
}
return a[x].first + a[x].second < a[y].first + a[y].second;
});
int cnt = 0, mx = -1e9;
for (int i = n; i; --i) {
if (a[ord[i]].second - a[ord[i]].first > mx) {
mx = a[ord[i]].second - a[ord[i]].first;
# | 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... |