Submission #1108390

#TimeUsernameProblemLanguageResultExecution timeMemory
1108390vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
129 ms12116 KiB
/*
		This solution was made by hihihah (Handle codeforces : hihihah) 
		The local date and time is: Mon Nov  4 10:42:59 2024
		The UTC date and time is: Mon Nov  4 03:42:59 2024
*/

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
const int N = 1e9 + 7;

int n;
pii a[500009];
ll f[500009];

void hihihah(){
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> a[i].first >> a[i].second;
    sort (a + 1, a + n + 1);
    
    for (int i = 1; i <= n; i ++)
        f[i] = f[i - 1] + a[i].second;

    ll mn = -a[1].first;
    ll res = 0;
    for (int i = 1; i <= n; i ++) {
        mn = min (mn, f[i - 1] - a[i].first);
        res = max (res, f[i] - a[i].first - mn);
    }

    cout << res;
}

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

    #define orz "mo"
    if(fopen(orz".inp", "r")){
        freopen(orz".inp", "r", stdin);
        freopen(orz".out", "w", stdout);
    }

    int t = 1;
    // cin >> t;
    while(t --){
        hihihah();
    }
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s";
    return 0;
}

Compilation message (stderr)

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