Submission #1087033

#TimeUsernameProblemLanguageResultExecution timeMemory
1087033quangminh412Art Exhibition (JOI18_art)C++14
50 / 100
1034 ms20868 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; pair<ll, ll> a[maxn]; signed main() { if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } faster(); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; // first: size // second: value sort(a + 1, a + n + 1); ll ans = -oo; for (int i = 1; i <= n; i++) { ll mn = a[i].first, mx = a[i].first; ll s = 0; for (int j = i; j >= 0; j--) { mn = a[j].first; s += a[j].second; 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...