Submission #922475

#TimeUsernameProblemLanguageResultExecution timeMemory
922475IUA_HasinArt Exhibition (JOI18_art)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define endl "\n" #define finp for(int i=0; i<n; i++) #define fknp for(int k=0; k<n; k++) #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define inpintn int n; cin>>n #define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define ll long long #define pb push_back #define answer cout<<ans<<endl #define INF (ll)(1e18) using namespace std; int main () { ll n; cin>>n; vector<vector<ll>> sizval; for(int i=0; i<n; i++){ ll a, b; cin>>a; cin>>b; sizval.push_back({a,b}); } sort(sizval.begin(), sizval.end()); ll arr[n+1]; arr[0] = 0; for(int i=1; i<=n; i++){ arr[i] = arr[i-1]+sizval[i-1][1]; } ll ans = sizval[0][1]-sizval[0][0]; ll ans1; for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ ll minn = sizval[i][0]; ll maxx = sizval[j][0]; ll s = arr[j+1] - arr[i]; ans1 = s+minn-maxx; ans = max(ans, ans1); } } ll anss = sizval[0][1]-sizval[0][0]; for(int i=0; i<n; i++){ ll aa = sizval[i][1]-sizval[i][0]; ll anss = max(anss, aa); } ans = max(ans, anss); cout<<ans<<endl; // for(int i=0; i<=n; i++){ // cout << arr[i] << " "; // } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...