# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
880213 | 2023-11-29T03:20:41 Z | ReLice | Art Exhibition (JOI18_art) | C++14 | 0 ms | 348 KB |
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() //#define sz size() #define bc back() #define ar array using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class _T> bool chmin(_T &x, const _T &y){ bool flag=false; if(x>y){ x=y;flag|=true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag=false; if (x<y){ x=y;flag|=true; } return flag; } #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18+7; const ll mod=998244353; const ll N=2e5+7; const ld eps=1e-9; void solve(){ ll i; ll n,m; ll a,b; cin>>n; deque<pair<ll,ll>> v(n); for(i=0;i<n;i++) cin>>v[i].fr>>v[i].sc; sort(all(v)); v.pf({0,0}); ll pref[n+5]; pref[0]=0; for(i=1;i<=n;i++) pref[i]=pref[i-1]+v[i].sc; for(i=1;i<=n;i++) pref[i]=pref[i]-v[i].fr+v[1].fr; ll ans=0,mn=inf; for(i=1;i<=n;i++){ ans=max(ans,pref[i]); ans=max(ans,pref[i]-mn); mn=min(mn,pref[i]); } cout<<ans<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |