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;
#define int long long
map <int, int> arr;
signed main () {
int n;
cin >> n;
while (n--) {
int x, y;
cin >> x >> y;
x /= 2;
arr[x] = max(arr[x], y);
}
vector <pair <int, int>> arr2;
for (auto i : arr) arr2.push_back(i);
int ans = 0;
int prev = 0;
for (int i = (int)arr2.size() - 2; i >= 0; i--) {
arr2[i].second = max(arr2[i].second, arr2[i + 1].second);
}
for (auto i : arr2) {
ans += (i.first - prev) * i.second;
prev = i.first;
}
ans *= 2;
cout << ans << '\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... |