Submission #140652

# Submission time Handle Problem Language Result Execution time Memory
140652 2019-08-04T04:07:56 Z meatrow Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 376 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (auto& p : a) {
        cin >> p.first >> p.second;
    }
    sort(a.begin(), a.end());
    ll kek = a[0].first;
    ll sum = a[0].second;
    ll ans = sum;
    for (int i = 1; i < n; i++) {
        sum += a[i].second;
        ans = max(ans, sum - a[i].first + kek);
        kek = max(kek, a[i].first - sum + a[i].second);
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -