Submission #60402

#TimeUsernameProblemLanguageResultExecution timeMemory
60402gusfringArt Exhibition (JOI18_art)C++14
100 / 100
416 ms227264 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int N;
pair<ll, ll> a[500005];

int main(){
  scanf("%d", &N);
  for(int i=1; i<=N; ++i) scanf("%lld %lld", &a[i].first, &a[i].second);
  sort(a + 1, a + N + 1);
  ll mp = 0, ans = -1000000000000000000LL;
  for(int i=1; i<=N; ++i){
    ans = max(ans, a[i].second + mp);
    mp = max(0ll, mp + a[i].second - (a[i + 1].first - a[i].first));
  }
  printf("%lld\n", ans);
  return 0;
}

Compilation message (stderr)

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