This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |