# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1008522 | 2024-06-26T14:01:27 Z | khanhtb | Art Exhibition (JOI18_art) | C++17 | 0 ms | 348 KB |
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll,ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 1e9+7; const ll inf = 1e18; const ll base = 31; const ll blocksz = 320; const ll N = 5e3+8; ll n,p[N]; pll a[N]; void solve(){ cin >> n; for(ll i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se; sort(a+1,a+n+1); for(ll i = 1; i <= n; i++) p[i] = p[i-1]+a[i].se; ll mx = 0; ll ans = 0; for(ll i = 1; i <= n; i++){ ans = max(ans,mx+p[i]-a[i].fi); mx = max(mx,a[i].fi-p[i-1]); } cout << ans; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if(fopen("test.inp","r")){ freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } ll T = 1; // cin >> T; while(T--){ solve(); cout << '\n'; } }
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 | - |