# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875659 | Isam | Art Exhibition (JOI18_art) | C++17 | 4 ms | 348 KiB |
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>
#define SPEED ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define a first
#define b second
#define pii pair<int, int>
using namespace std;
const int sz = 2e5 + 5;
const int inf = 1e9 + 7;
int ans = -inf;
int n;
pii c[sz];
signed main(){
SPEED;
cin >> n;
for(register int i = 1; i <= n; ++i){
cin >> c[i].a >> c[i].b;
}
for(register int mask = 1; mask < (1LL << n); ++mask){
int s(0), mxa{-inf}, mna{inf};
for(register int i = 1; i <= n; ++i){
if(mask & (1LL << (i-1))){
s += c[i].b;
mxa = max(mxa, c[i].a), mna = min(mna, c[i].a);
}
}
ans = max(ans, s - mxa + mna);
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | 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... |