Submission #707979

#TimeUsernameProblemLanguageResultExecution timeMemory
707979TAhmed33Unija (COCI17_unija)C++98
80 / 100
1072 ms58416 KiB
#include <bits/stdc++.h> using namespace std; #define int long long map <int, int> arr; signed main () { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; while (n--) { int x, y; cin >> x >> y; x /= 2; arr[x] = max(arr[x], y); } vector <pair <int, int>> arr2; for (auto i : arr) arr2.push_back(i); 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...