Submission #526084

# Submission time Handle Problem Language Result Execution time Memory
526084 2022-02-13T16:49:01 Z benjaminkleyn Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 292 KB
    #pragma GCC optimize("O3")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("avx,avx2,fma")
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;

    void solve()
    {
        int n;
        cin >> n;
        vector<ll> a(n), b(n);
        for (int i = 0; i < n; i++)
            cin >> a[i] >> b[i];

        ll S = b[0], mn = a[0], mx = a[0];
        for (int i = 1; i < n; i++)
        {
            ll newMn = min(mn, a[i]), newMx = max(mx, a[i]);
            if (S + b[i] - (newMx - newMn) > S - (mx - mn))
                S += b[i], mn = newMn, mx = newMx;
        }

        cout << S - (mx - mn) << '\n';
    }

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        solve();

        return 0;
    }
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -