Submission #486856

#TimeUsernameProblemLanguageResultExecution timeMemory
486856TypeYippieArt Exhibition (JOI18_art)C++14
100 / 100
195 ms28908 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5+5; int n; pair<long long, long long> art[N]; long long pref[N]; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%lld%lld", &art[i].first, &art[i].second); } sort(art+1, art+n+1); pref[0] = 0; for(int i = 1; i <= n; i++){ pref[i] = pref[i-1]+art[i].second; } priority_queue<long long> pq; long long ans = 0; for(int i = n; i > 0; i--){ pq.push(pref[i]-art[i].first); ans = max(ans, (pq.top()-pref[i-1])+art[i].first); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
art.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lld%lld", &art[i].first, &art[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...