Submission #542215

# Submission time Handle Problem Language Result Execution time Memory
542215 2022-03-25T18:22:29 Z zxcvbnm Unija (COCI17_unija) C++14
100 / 100
307 ms 31056 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(auto& i : a) {
        cin >> i.first >> i.second;
        i.second /= 2;
    }

    a.push_back({0, 0});
    sort(a.begin(), a.end(), [&](const auto& i, const auto& j) {
        return i.second > j.second;
    });

    ll ans = 0;
    int mx = 0;
    for(int i = 0; i < (int) a.size()-1; i++) {
        mx = max(mx, a[i].first);
        ans += (a[i].second - (a[i+1].second)) * mx;
    }

    ans *= 2;
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 304 ms 30908 KB Output is correct
2 Correct 307 ms 31056 KB Output is correct
3 Correct 275 ms 30904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1060 KB Output is correct
2 Correct 8 ms 1072 KB Output is correct
3 Correct 7 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3148 KB Output is correct
2 Correct 27 ms 3152 KB Output is correct
3 Correct 33 ms 3292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 9016 KB Output is correct
2 Correct 75 ms 9060 KB Output is correct
3 Correct 75 ms 9048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 279 ms 30908 KB Output is correct
2 Correct 300 ms 30908 KB Output is correct
3 Correct 272 ms 30920 KB Output is correct