Submission #45664

#TimeUsernameProblemLanguageResultExecution timeMemory
45664realityArt Exhibition (JOI18_art)C++17
100 / 100
958 ms244224 KiB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void) {
    int n;
    scanf("%d",&n);
    map < ll , ll > M;
    for (int i = 0;i < n;++i) {
        ll u,v;
        scanf("%lld%lld",&u,&v);
        M[u] += v;
    }
    vector < pair < ll , ll > > s;
    for (auto it : M)
        s.pb(it);
    n = s.size();
    vl ss;
    for (int i = 1;i < n;++i)
        s[i].se += s[i - 1].se;
    ll mn = -s[0].fi;
    ll ans = 0;
    for (int i = 1;i < n;++i) {
        if (i > 0)
            smin(mn,s[i - 1].se - s[i].fi);
        smax(ans,s[i].se - s[i].fi - mn);
    }
    cout << ans << '\n';
    return 0;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
art.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&u,&v);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...