제출 #71442

#제출 시각아이디문제언어결과실행 시간메모리
71442win11905Art Exhibition (JOI18_art)C++11
100 / 100
352 ms227308 KiB
#include <bits/stdc++.h>
using namespace std;

#define long long long
#define pll pair<long, long>
#define x first
#define y second

int n;
long pref, ans, lhs = -1e18;

int main() {
    scanf("%d", &n);
    vector<pll> V;
    for(int i = 0; i < n; ++i) {
        long a, b; scanf("%lld %lld", &a, &b);
        V.emplace_back(a, b);
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < n; ++i) {
        long a, b; tie(a, b) = V[i];
        lhs = max(lhs, a - pref);
        pref += b;
        ans = max(ans, pref - a + lhs);
    }
    printf("%lld\n", ans);
}

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

art.cpp: In function 'int main()':
art.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         long a, b; scanf("%lld %lld", &a, &b);
                    ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...