Submission #246348

#TimeUsernameProblemLanguageResultExecution timeMemory
246348NONAMEUnija (COCI17_unija)C++14
100 / 100
425 ms31160 KiB
#include <bits/stdc++.h> #define dbg(x) cerr << #x << " = " << x << "\n" #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie() using namespace std; using ll = long long; using ld = long double; bool cmp(pair <ll, ll> x, pair <ll, ll> y) { return (x.second == y.second) ? x.first > y.first : x.second > y.second; } int main() { fast_io; int n; vector <pair <ll, ll> > v; cin >> n; for (int i = 0; i < n; ++i) { ll x, y; cin >> x >> y; x /= 2, y /= 2; v.push_back(make_pair(x, y)); } sort(v.begin(), v.end(), cmp); ll ans = 0, mx = 0; for (int i = 0; i < n; ++i) { ll x = v[i].first, y = v[i].second; ans += y * max(0ll, x - mx); mx = max(mx, x); } cout << ans * 4 << "\n"; }
#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...