제출 #314228

#제출 시각아이디문제언어결과실행 시간메모리
314228radaiosm7Art Exhibition (JOI18_art)C++98
100 / 100
288 ms20900 KiB
#include <bits/stdc++.h>
using namespace std;
int n, i;
long long ans, curr;
pair<long long, long long> numbers[500005];

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

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

  sort(numbers, numbers+n);

  ans = numbers[0].second;
  curr = ans;

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

  printf("%lld\n", ans);

  return 0;
}

컴파일 시 표준 에러 (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("%d", &n);
      |   ~~~~~^~~~~~~~~~
art.cpp:11:12: 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...