제출 #126359

#제출 시각아이디문제언어결과실행 시간메모리
126359EntityITArt Exhibition (JOI18_art)C++14
100 / 100
272 ms12604 KiB
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second

const int N = (int)5e5 + 5;
const long long infll = (long long)1e18 + 123;
int n;
long long ans = -infll, prv = -infll;
pair<long long, long long> a[N];

int main () {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%lld %lld", &a[i].fi, &a[i].se);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) a[i].se += a[i - 1].se;

    for (int i = 1; i <= n; ++i) {
        prv = max(prv, a[i].fi - a[i - 1].se);
        ans = max(ans, a[i].se - a[i].fi + prv);
    }

    printf("%lld", 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]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:16:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; ++i) scanf("%lld %lld", &a[i].fi, &a[i].se);
                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...