# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078738 | _callmelucian | Advertisement 2 (JOI23_ho_t2) | C++14 | 123 ms | 15604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;
#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())
struct person {
int E, X;
person() : E(0), X(0) {}
person (int E) : E(E), X(X) {}
friend istream& operator >> (istream &inp, person &cur) {
inp >> cur.X >> cur.E;
return inp;
}
int sum() { return E + X; }
int diff() { return E - X; }
bool operator < (person o) {
if (sum() == o.sum()) return diff() < o.diff();
return sum() < o.sum();
}
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<person> vec(n);
for (int i = 0; i < n; i++) cin >> vec[i];
sort(all(vec));
vector<int> line;
for (int i = 0; i < n; i++) {
while (line.size() && line.back() <= vec[i].diff()) line.pop_back();
line.push_back(vec[i].diff());
}
cout << line.size();
return 0;
}
Compilation message (stderr)
# | 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... |