Submission #1308471

#TimeUsernameProblemLanguageResultExecution timeMemory
1308471nickieArt Exhibition (JOI18_art)C++20
0 / 100
0 ms332 KiB
#include <algorithm>
#include <cstdio>
#include <limits>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  vector<pair<long long, long long>> p(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &p[i].first);
    scanf("%lld", &p[i].second);
  }
  sort(p.begin(), p.end());
  long long s = 0;
  long long first = numeric_limits<long long>::min();
  long long result = 0;
  for (auto [a, b] : p) {
    first = max(first, a - s);
    s += b;
    int second = s - a;
    result = max(result, first + second);
  }
  printf("%lld\n", result);
}

Compilation message (stderr)

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