Submission #1273795

#TimeUsernameProblemLanguageResultExecution timeMemory
1273795baotoan655Art Exhibition (JOI18_art)C++20
100 / 100
122 ms8264 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int N = 5e5 + 5; int n; pair<long long, int> a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); file("A") else file("task"); cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1, greater<pair<long long, int>>()); long long ans = 0; long long sum = 0; long long mn = 1e16; for(int i = 1; i <= n; ++i) { mn = min(mn, sum + a[i].first); sum += a[i].second; ans = max(ans, sum + a[i].first - mn); } cout << ans << '\n'; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:13:5: note: in expansion of macro 'file'
   13 |     file("A") else file("task");
      |     ^~~~
art.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:13:5: note: in expansion of macro 'file'
   13 |     file("A") else file("task");
      |     ^~~~
art.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:13:20: note: in expansion of macro 'file'
   13 |     file("A") else file("task");
      |                    ^~~~
art.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:13:20: note: in expansion of macro 'file'
   13 |     file("A") else file("task");
      |                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...