#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 |
1 |
Incorrect |
4 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |