Submission #1228893

#TimeUsernameProblemLanguageResultExecution timeMemory
1228893nguthianmangcayArt Exhibition (JOI18_art)C++20
100 / 100
108 ms8264 KiB
#include<bits/stdc++.h> using namespace std; const int N=5e5+3; const long long inf=LLONG_MIN; #define ll long long #define fi first #define se second #define pi pair pair<ll,ll>a[N]; int32_t main(){ cin.tie(0)->sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].fi>>a[i].se; } sort(a+1,a+1+n); ll ma=-inf; ll sum=0; ll best=-inf; for(int i=1;i<=n;i++){ best=max(best,a[i].fi-sum); sum+=a[i].se; ma=max(ma,sum-a[i].fi+best); } cout<<ma; }

Compilation message (stderr)

art.cpp: In function 'int32_t main()':
art.cpp:18:11: warning: integer overflow in expression of type 'long long int' results in '-9223372036854775808' [-Woverflow]
   18 |     ll ma=-inf;
      |           ^~~~
art.cpp:20:13: warning: integer overflow in expression of type 'long long int' results in '-9223372036854775808' [-Woverflow]
   20 |     ll best=-inf;
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...