Submission #1228850

#TimeUsernameProblemLanguageResultExecution timeMemory
1228850Tony_TungArt Exhibition (JOI18_art)C++17
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>
#define task ""
#define ll long long
#define fi first
#define se second
using namespace std;

const int N = 5e5 + 5;
pair<ll, ll> p[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }

    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> p[i].fi >> p[i].se;
    sort(p+1, p+n+1);
    ll res = 0, mi = LLONG_MAX;
    for (int i = 1; i <= n; i++)
    {
        p[i].se += p[i-1].se;
        if (i >= 2) res = max(res, p[i].se - p[i].fi - mi);
        else res = max(res, p[i].se);
        mi = min(mi, p[i-1].se - p[i].fi);
    }
    cout << res;

    return 0;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...