제출 #75106

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

using namespace std;

//#define FILE_IO

typedef long long LL;
typedef pair<LL, LL> pll;

int N;
pll v[500005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        LL x, y;
        scanf("%lld%lld", &x, &y);
        v[i] = {x, y};
    }
    sort(v + 1, v + N + 1);

    LL ans = -(1LL << 60), sum = 0LL, bst = -(1LL << 60);
    for(int i = 1; i <= N; i++)
    {
        bst = max(bst, v[i].first - sum);
        sum += v[i].second;
        ans = max(ans, sum - v[i].first + bst);
    }

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

    return 0;
}

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

art.cpp: In function 'int main()':
art.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
art.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld", &x, &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...