Submission #1178755

#TimeUsernameProblemLanguageResultExecution timeMemory
1178755cpdreamerArt Exhibition (JOI18_art)C++20
100 / 100
202 ms35660 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair #define F first #define all(v) v.begin(),v.end() #define V vector #define pb push_back #define S second const ll MOD=(ll)998244353; void file() { freopen("input.txt.txt", "r", stdin); freopen("output.txt.txt", "w", stdout); } long long binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } ll md[(int)5e5+1]; ll modinverse(ll a,ll m){ return binpow(a,MOD-2,MOD); } ll fact[(int)5e5+1]; ll nck(int n,int k){ ll ans=fact[n]; ans*=md[n-k]; ans%=MOD; ans*=md[k]; ans%=MOD; return ans; } ll dp[27][(int)3e5]; void solve() { int n; cin>>n; P<ll,ll>A[n+1]; for(int i=1;i<=n;i++){ cin>>A[i].F>>A[i].S; } sort(A+1,A+n+1); ll pref[n+1]; pref[0]=0LL; for(int i=1;i<=n;i++){ pref[i]=A[i].S+pref[i-1]; } ll mx=-1e18; ll ans=0; set<ll>st; for(int i=1;i<=n;i++){ st.insert(-pref[i-1]+A[i].F); if(!st.empty()){ ans=max(ans,pref[i]-A[i].F+*prev(st.end())); } } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // file(); solve(); }

Compilation message (stderr)

art.cpp: In function 'void file()':
art.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("input.txt.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("output.txt.txt", "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...