제출 #469924

#제출 시각아이디문제언어결과실행 시간메모리
469924IvnFArt Exhibition (JOI18_art)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ull unsigned long long #define fi first #define se second #define ld long double ll n, sums; pair<ll, ll>arr[100005]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i=1;i<=n;++i){ cin >> arr[i].fi >> arr[i].se; sums+=arr[i].se; } sort(arr+1, arr+1+n); ll l=1, r=n, maks=sums-(arr[n].fi-arr[1].fi); while(l<r){ ll hapus_depan=(sums-arr[l].se)-(arr[r].fi-arr[l+1].fi); ll hapus_blkg=(sums-arr[r].se)-(arr[r-1].fi-arr[l].fi); if(hapus_depan > hapus_blkg){ maks=max(maks, hapus_depan); sums-=arr[l].se; l++; } else{ maks=max(maks, hapus_blkg); sums-=arr[r].se; r--; } } cout << maks << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...