Submission #1144512

#TimeUsernameProblemLanguageResultExecution timeMemory
1144512MedetbekArt Exhibition (JOI18_art)C++17
100 / 100
111 ms19928 KiB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #include <bits/stdc++.h> #define ll long long #define int long long #define all(v) v.begin(), v.end() #define nl '\n' #define pb push_back #define sz(s) (int)(s).size() #define f first #define s second #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; const ll N = 1e5+10, MX = 1e18+1, MOD = 1e9 + 7; void solve(){ ll n; cin >> n; ll a[n + 1], b[n + 1]; pair <int, int> pr[n+1]; ll ans = 0; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; pr[i] = {a[i],b[i]}; ans = max(ans, b[i]); } sort(pr + 1, pr + 1 + n); for(int i = 1; i <= n; i++){ a[i]=pr[i].f; b[i]=pr[i].s; } ll p[n+1]; p[0]=0; for(int i = 1; i <= n; i++){ p[i] = p[i-1]+b[i]; } ll mn = -MX; for(int i = 1; i <= n; i++){ mn = max(a[i]-p[i-1], mn); ans = max(ans, p[i]-a[i] + mn); } cout << ans << nl; } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); ll ql =1; while(ql--){ solve(); } }

Compilation message (stderr)

art.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | 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...