Submission #1306729

#TimeUsernameProblemLanguageResultExecution timeMemory
1306729ng.annhaatArt Exhibition (JOI18_art)C++20
100 / 100
123 ms8260 KiB
/* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░ ░░░░░░░░ ░░░░░ ░ ░ ░░░░ ░░░░░ ░░░░░░ ░░░░ ▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒▒ ▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒ ▒▒ ▓▓▓▓ ▓▓▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓ ▓▓▓▓▓▓ ▓▓▓ ▓ ▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓▓ ▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓▓▓ ▓▓▓▓▓ ▓▓ ▓▓▓▓ ▓▓ █ █████████ ███ ████████ █████ ████ █████ ██████ ██████ ███████████████████████████████████████████████████████████████████████████████ ▄▄▄ ███▄ █ ███▄ █ ██░ ██ ▄▄▄ ▄▄▄ ▄▄▄█████▓ ▒████▄ ██ ▀█ █ ██ ▀█ █ ▒▓██░ ██ ▒████▄ ▒████▄ ▓ ██▒ ▓▒ ▒██ ▀█▄ ▓██ ▀█ ██▒▓██ ▀█ ██▒░▒██▀▀██ ▒██ ▀█▄ ▒██ ▀█▄ ▒ ▓██░ ▒░ ░██▄▄▄▄██▓██▒ ▐▌██▒▓██▒ ▐▌██▒ ░▓█ ░██ ░██▄▄▄▄██░██▄▄▄▄██░ ▓██▓ ░ ▓█ ▓██▒██░ ▓██░▒██░ ▓██░ ░▓█▒░██▓ ▓█ ▓██ ▓█ ▓██ ▒██▒ ░ ▒▒ ▓▒█░ ▒░ ▒ ▒ ░ ▒░ ▒ ▒ ▒ ░░▒░▒ ▒▒ ▓▒█ ▒▒ ▓▒█ ▒ ░░ ░ ▒▒ ░ ░░ ░ ▒░░ ░░ ░ ▒░ ▒ ░▒░ ░ ░ ▒▒ ░ ▒▒ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ */ //#include <bits/BaoMinhTranc++.h> #include <bits/stdc++.h> #define int int64_t //#define ll int64_t #define ld long double #define ii pair<int,int> #define iii pair<int,ii> #define fi first #define se second #define ALL(x) x.begin(),x.end() #define ALLr(x) x.rbegin(),x.rend() #define upgrade ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define name "SKIBIDI" using namespace std; const int Max=3e5; const int N=5e5+3; const int INF=1e18; const int MOD=1e9+7; const int MOD2=1e9+8; const int base=26; const int LOG=20; template<class X,class Y> bool minimize(X& x,const Y& y) { if(x>y){ x=y; return 1; }return 0; } template<class X,class Y> bool maximize(X& x,const Y& y) { if(x<y){ x=y; return 1; }return 0; } int n; ii a[N]; void solve() { cin>>n; for(int i=1;i<=n;i++)cin>>a[i].fi>>a[i].se; sort(a+1,a+n+1); for(int i=1;i<=n;i++)a[i].se+=a[i-1].se; int lef=-INF,ans=-INF; for(int i=1;i<=n;i++){ maximize(lef,a[i].fi-a[i-1].se); maximize(ans,(a[i].se-a[i].fi)+lef); } cout<<ans; } void prepare() { } signed main() { upgrade if(fopen(name".INP","r")){ freopen(name".INP","r",stdin); freopen(name".OUT","w",stdout); } prepare(); int test=1; // cin>>test; while(test--)solve(); return 0; } /* ░▓▓ ░▒▒▒ ░▒▒▒▒▒▒░░░ ░▓▓ ▓▒ ▒▓▓▓▓▓▓▓▓▓▓▓▓▒ ░▓▓▓▓▓▓▓▓▓▓▓▒░ ▒▓▓▒ ▒▒▒▒░ ░░░░▒░▒▒▒▒▒▒ ░▓▓ ░░▒▒▒▒▒░░ ▒▓▓▒ ▒▓▓░ ░▓▓▒ ░▓▓▓▒ ░▒▓▓░░▓▓▒ ▒▒▒ ▒▒▒▒▒▒░░░▒▒▒▒▒▒▒▒▒▒▒░ ░▓▓▓▒▒▒▒▒▒▒▒▒▒▓▒▒░ ▓▓▓▓▒ ░▓▓▒ ▒▓▓▒ ░▓▓▓░ ░▒░ ░▒▒▒▒▒▒▒▒ ▒▒▒░ ▒▒▒ ░▓▓ ░▓▓░ ▓▓▓ ░▒▒▒ ▒▒▒ ░▒▒ ▒▓▒ ▒▓▒ ▓▓▓ ░░ ▒▒░ ▒▒▒ ▒▒░ ▓▓▓ ░▓▒ ░▓▓▓ ░▒ ▒▒░ ▒▒░ ▒▒░ ▒▒▒ ▓▓▓░ ░▓▒ ░▓▓▓▒ ▒▒▒ ░▒▒▒░ ░▒▒░ ░▒▒ ▒▒▒ ▓▓▓▒ ▒▓▒ ▓▓▓░ ░ ▒▒░ ▒▒▒ ▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒ ░▓▓▓ ░▓▓▒ ▒▓▓▓▒ ░▓▓▓▓▒ ░▒▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒░ ░▓▓▓ ░▒ ░▓▓▓▓▓▓▒░ ▒▓▓▓▓▓▒▓▓▒ ▒▒▒▒▒▒▒░ ░▒▒▒▒▒▒▒░ ▓▓▓▓▒▒ ▒▓▓▓▓ ░░▓▓▓▓▓▓▓▓▒░░ ▒▓▒ ░▒▒▒▒░ ░▒▓▓▓▓▓▓▓▓▒░ ▒▓▓░ ▒▒░ ▓▒ ▒▓▓░ ▒▒▒░ ▓▓▒ ░▓▓▒ ░▒▒▒▒ ▓▓▓░ ▒▓▓▓ ░▒▒▒ ░▓▓▓▓░ ░▓▓▓▒ ░▓▓▓▓▓▒▒░░░ ░░░▒▒▓▓▓▓░ ░▒▒▒▒▒▒▒▒░ */

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...