#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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
596 KB |
Output is correct |
2 |
Correct |
4 ms |
696 KB |
Output is correct |
3 |
Correct |
4 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
52344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
2652 KB |
Output is correct |
2 |
Correct |
26 ms |
2620 KB |
Output is correct |
3 |
Correct |
26 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
8428 KB |
Output is correct |
2 |
Correct |
91 ms |
8452 KB |
Output is correct |
3 |
Correct |
102 ms |
8580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
358 ms |
22620 KB |
Output is correct |
2 |
Correct |
347 ms |
22680 KB |
Output is correct |
3 |
Correct |
358 ms |
22728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
52232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |