Submission #1109191

#TimeUsernameProblemLanguageResultExecution timeMemory
1109191vjudge1Art Exhibition (JOI18_art)C++14
100 / 100
183 ms17224 KiB
#include <bits/stdc++.h>
using namespace std;

#define NAME "name"

#define ll __int128
#define pb push_back
#define pii pair<ll, ll>
#define fi first
#define se second
#define endl "\n"

#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

const int LIM = 1e6 + 3;
const int INF = 1e9 + 9;
const int mod = 1e9 + 7;

int n;
pii a[LIM];

void printt(__int128 x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9)
        printt(x / 10);
    putchar(x % 10 + '0');
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if (ifstream(NAME ".inp"))
    {
        freopen(NAME ".inp", "r", stdin);
        freopen(NAME ".out", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        long long x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    sort(a + 1, a + n + 1);
    ll mines = a[1].fi, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        a[i].se += a[i - 1].se;
        mines = min(mines, a[i - 1].se - a[i].fi);
        ans = max(ans, a[i].se - a[i].fi - mines);
    }
    printt(ans);

    return 0;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen(NAME ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen(NAME ".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...