제출 #163182

#제출 시각아이디문제언어결과실행 시간메모리
163182fenech20Art Exhibition (JOI18_art)C++14
100 / 100
391 ms20984 KiB
/**
 * Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define sz(a) (int)a.size()

typedef long long ll;

int main() {
  ll n;
  scanf("%lld", &n);
  vector<pair<ll, ll> > a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &a[i].first, &a[i].second);
  }
  sort(a.begin(), a.end());
  ll prefix = 0, ans = -0x3f33f3f3f3f3f, mn = 0x3f3f3f3f3f3f;
  for (int i = 0; i < n; i++) {
    mn = min(mn, prefix - a[i].first);
    prefix += a[i].second;
    ans = max(ans, prefix - mn - a[i].first);
//    fprintf(stderr, "mn = %d, prefix = %d, ans = %d\n", mn, prefix, ans);
  }
  printf("%lld", ans);
}

//

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &n);
   ~~~~~^~~~~~~~~~~~
art.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &a[i].first, &a[i].second);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…