#include <bits/stdc++.h>
const int MAX_N = 1000000;
int N, S;
std::pair<int, int> P[MAX_N + 1];
auto P_compare = [](const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) -> bool {
return lhs.first > rhs.first || (lhs.first == rhs.first && lhs.second > rhs.second);
};
void solve()
{
// Sort the rectangles by their width
std::sort(std::begin(P), std::begin(P) + N, P_compare);
P[N].first = 0;
P[N].second = 0;
int m_h = P[0].second;
S = 0;
for (int i = 1; i <= N; ++i) {
S += (P[i - 1].first - P[i].first) * m_h;
if (P[i].second > m_h)
m_h = P[i].second;
}
}
int main()
{
std::cin >> N;
for (int i = 0; i < N; ++i) {
std::cin >> P[i].first >> P[i].second;
P[i].first /= 2;
P[i].second /= 2;
}
solve();
std::cout << (S * 4);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1050 ms |
20456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
122 ms |
2460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
364 ms |
6664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1059 ms |
19744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |