제출 #493283

#제출 시각아이디문제언어결과실행 시간메모리
493283aris12345678Art Exhibition (JOI18_art)C++14
100 / 100
226 ms24772 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
#define X first
#define Y second

const int mxN = 500005;
pii art[mxN];
ll pref[mxN];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%lld %lld", &art[i].X, &art[i].Y);
    sort(art+1, art+n+1);
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i-1]+art[i].Y;
    ll ans = art[1].Y-art[1].X, mn = pref[0]-art[1].X;
    for(int i = 2; i <= n; i++) {
        mn = min(mn, pref[i-1]-art[i].X);
        ans = max(ans, pref[i]-art[i].X-mn);
    }
    printf("%lld\n", ans);
    return 0;
}

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

art.cpp: In function 'int main()':
art.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
art.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld %lld", &art[i].X, &art[i].Y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...