이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |