Submission #1087032

#TimeUsernameProblemLanguageResultExecution timeMemory
1087032quangminh412Art Exhibition (JOI18_art)C++14
10 / 100
5 ms604 KiB
#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)

art.cpp: In function 'int main()':
art.cpp:24:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   freopen("test.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   freopen("test.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...