Submission #707982

#TimeUsernameProblemLanguageResultExecution timeMemory
707982TAhmed33Unija (COCI17_unija)C++98
100 / 100
299 ms31020 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector <pair <int, int>> arr2; signed main () { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; while (n--) { int x, y; cin >> x >> y; x /= 2; arr2.push_back({x, y}); } sort(arr2.begin(), arr2.end()); int ans = 0; int prev = 0; for (int i = (int)arr2.size() - 2; i >= 0; i--) { arr2[i].second = max(arr2[i].second, arr2[i + 1].second); } for (auto i : arr2) { ans += (i.first - prev) * i.second; prev = i.first; } ans *= 2; cout << ans << '\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...