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>
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;
}
# | 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... |