Submission #131236

# Submission time Handle Problem Language Result Execution time Memory
131236 2019-07-16T20:36:41 Z joylintp Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 380 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

pair<int, int> arr[500001];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> arr[i].first >> arr[i].second;
    sort(arr, arr + n + 1);
    for (int i = 1; i <= n; i++)
        arr[i].second += arr[i - 1].second;

    int ans = arr[1].second, now, i = 1;
    for (int j = 1; j <= n; j++)
    {
        now = arr[j].second - arr[i - 1].second - arr[j].first + arr[i].first;
        while (i < j && now <= arr[j].second - arr[i].second - arr[j].first + arr[i + 1].first)
            i++, now = arr[j].second - arr[i].second - arr[j].first + arr[i + 1].first;
        ans = max(ans, now);
    }
    cout << ans << '\n';

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