# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087032 | quangminh412 | Art Exhibition (JOI18_art) | C++14 | 5 ms | 604 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>
using namespace std;
/*
John Watson
https://codeforces.com/profile/quangminh98
Mua Code nhu mua Florentino !!
*/
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
const ll oo = 1e18;
const int maxn = 5e5 + 9;
int n;
ll a[maxn], b[maxn];
signed main()
{
if (fopen("test.inp", "r"))
{
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
faster();
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
ll ans = -oo;
for (int mask = 1; mask < (1 << n); mask++)
{
ll s = 0;
ll mn = oo, mx = -oo;
for (int i = 0; i < n; i++)
if (mask >> i & 1)
{
mn = min(mn, a[i]);
mx = max(mx, a[i]);
s += b[i];
}
ans = max(ans, s - (mx - mn));
}
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... |