Submission #595477

#TimeUsernameProblemLanguageResultExecution timeMemory
595477BelphegorArt Exhibition (JOI18_art)C++14
10 / 100
5 ms452 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll A[16],B[16]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; for(int i=0; i<n; i++) cin>>A[i]>>B[i]; ll ans = 0; for(int i=1; i<(1<<n); i++){ ll s = 0; ll mx = -1,mn = INT64_MAX; for(int j=0; j<n; j++){ if(i&(1<<j)){ s+=B[j]; mn = min(mn,A[j]); mx = max(mx,A[j]); } } ans = max(ans,s-(mx-mn)); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...