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>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;
using ld = long double;
bool cmp(pair <ll, ll> x, pair <ll, ll> y) {
return (x.second == y.second) ? x.first > y.first : x.second > y.second;
}
int main() {
fast_io;
int n;
vector <pair <ll, ll> > v;
cin >> n;
for (int i = 0; i < n; ++i) {
ll x, y;
cin >> x >> y;
x /= 2, y /= 2;
v.push_back(make_pair(x, y));
}
sort(v.begin(), v.end(), cmp);
ll ans = 0, mx = 0;
for (int i = 0; i < n; ++i) {
ll x = v[i].first, y = v[i].second;
ans += y * max(0ll, x - mx);
mx = max(mx, x);
}
cout << ans * 4 << "\n";
}
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |