Submission #136861

#TimeUsernameProblemLanguageResultExecution timeMemory
136861RiscadoAUnija (COCI17_unija)C++14
50 / 100
1061 ms7692 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...