Submission #162776

#TimeUsernameProblemLanguageResultExecution timeMemory
162776fenech20Art Exhibition (JOI18_art)C++14
100 / 100
324 ms20984 KiB
/** * Martin Leshko (leshko.martin@gmail.com) */ #include <bits/stdc++.h> using namespace std; #define forn(i, n) for (int i = 0; i < (int)n; i++) #define sz(a) (int)a.size() int main() { long long n; scanf("%lld", &n); vector< pair<long long, long long> > a(n); for (int i = 0; i < n; i++) scanf("%lld%lld", &a[i].first, &a[i].second); sort(a.begin(), a.end()); long long prefix = 0, ans = -0x3f3f3f3f3f3f, mn = 0x3f3f3f3f3f; for (int i = 0; i < n; i++) { mn = min(prefix - a[i].first, mn); prefix += a[i].second; ans = max(ans, prefix - mn - a[i].first); } printf("%lld", ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &n);
   ~~~~~^~~~~~~~~~~~
art.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &a[i].first, &a[i].second);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...