Submission #71443

#TimeUsernameProblemLanguageResultExecution timeMemory
71443win11905Art Exhibition (JOI18_art)C++11
100 / 100
365 ms10616 KiB
#include <bits/stdc++.h> using namespace std; #define long long long #define pll pair<long, long> #define x first #define y second int n; long pref, ans, lhs = -1e18; int main() { scanf("%d", &n); vector<pll> V; V.reserve(n+1); for(int i = 0; i < n; ++i) { long a, b; scanf("%lld %lld", &a, &b); V.emplace_back(a, b); } sort(V.begin(), V.end()); for(int i = 0; i < n; ++i) { long a, b; tie(a, b) = V[i]; lhs = max(lhs, a - pref); pref += b; ans = max(ans, pref - a + lhs); } printf("%lld\n", ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         long a, b; scanf("%lld %lld", &a, &b);
                    ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...