Submission #1016565

#TimeUsernameProblemLanguageResultExecution timeMemory
1016565phongArt Exhibition (JOI18_art)C++17
0 / 100
1 ms2396 KiB
#include<bits/stdc++.h> #define ll long long const int nmax = 5e5 + 5, N = 4e5; const ll oo = 1e18; const int lg = 18, M = 4e3; const int base = 2e5, mod = 1e9 + 7; #define pii pair<int, int> #define fi first #define se second #define endl "\n" #define debug(a, n) for(int i = 1; i <= n; ++i) cout << a[i] << ' ';cout << endl using namespace std; int n; pii a[nmax]; ll s[nmax], pre[nmax]; main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); // freopen("code.inp", "r", stdin); // freopen("code.out", "w", stdout); cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i].fi >> a[i].se; sort(a +1 , a + 1 + n); pre[0] = -oo; ll ans = -oo; for(int i = 1; i <= n; ++i){ s[i] = s[i - 1] + a[i].se; pre[i] = max(pre[i - 1], -s[i - 1] + a[i].fi); ans = max(ans, s[i] - a[i].fi + pre[i]); } cout << ans; } /* 1_t1 + 1 */

Compilation message (stderr)

art.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...