Submission #52144

#TimeUsernameProblemLanguageResultExecution timeMemory
52144evpipisArt Exhibition (JOI18_art)C++14
100 / 100
341 ms230984 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; typedef pair<int, int> ii; const int len = 5e5+5; const ll inf = 1e17; pair<ll, ll> arr[len]; ll pref[len]; int main(){ int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld %lld", &arr[i].fi, &arr[i].se); sort(arr+1, arr+1+n); for (int i = 1; i <= n; i++) pref[i] = arr[i].se + pref[i-1]; ll ans = 0, mx = -inf; for (int i = n; i >= 1; i--){ mx = max(mx, pref[i]-arr[i].fi); ans = max(ans, mx + arr[i].fi-pref[i-1]); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

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