Submission #542056

#TimeUsernameProblemLanguageResultExecution timeMemory
542056lunchboxArt Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long ans, mx; int n; scanf("%d", &n); vector<pair<long long, long long>> a(n); for (auto &[x, y] : a) scanf("%lld%lld", &x, &y); sort(a.begin(), a.end()); for (int i = 0; i + 1 < n; i++) a[i + 1].second += a[i].second; mx = 0, ans = -0x3f3f3f3f3f3f3f3f; for (int i = 0; i < n; i++) { ans = max(ans, a[i].second - a[i].first + mx); mx = max(mx, a[i].first - (i == 0 ? 0 : a[i - 1].second)); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

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