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;
using ll = long long;
int n;
vector<ll> a, b;
int main(){
cin >> n;
a.resize(n);
b.resize(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 cur = 0, mn = 1e15, mx = 0;
for(int j = 0; j < n; j++){
if(i >> j & 1){
cur += b[j];
mn = min(mn, a[j]);
mx = max(mx, a[j]);
}
}
ans = max(ans, cur - 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... |