Submission #309566

#TimeUsernameProblemLanguageResultExecution timeMemory
309566radaiosm7Art Exhibition (JOI18_art)C++98
50 / 100
21 ms896 KiB
#include <bits/stdc++.h>
using namespace std;
long long i, j, n, ans;
pair<long long, long long> numbers[5005];
long long pref[5005];

int main() {
  scanf("%lld", &n);

  for (i=1; i <= n; i++) {
    scanf("%lld%lld", &numbers[i].first, &numbers[i].second);
  }

  sort(numbers+1, numbers+n+1);
  pref[0] = 0LL;

  for (i=1; i <= n; i++) {
    pref[i] = pref[i-1] + numbers[i].second;
  }

  ans = -100LL;

  for (i=1; i <= n; i++) {
    for (j=i; j <= n; j++) {
      ans = max(ans, pref[j]-pref[i-1]-numbers[j].first+numbers[i].first);
    }
  }

  printf("%lld\n", ans);
  return 0;
}

Compilation message (stderr)

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