제출 #159881

#제출 시각아이디문제언어결과실행 시간메모리
159881dantoh000Art Exhibition (JOI18_art)C++14
100 / 100
337 ms21112 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
main(){
    int n;
    scanf("%lld",&n);
    ii a[n];
    for (int i = 0; i < n; i++){
        scanf("%lld%lld",&a[i].first,&a[i].second);
    }
    sort(a,a+n);
    int m = -a[0].first;
    int cur = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        cur += a[i].second;
        //printf("%d %d %d -> ",cur,m,a[i].first);
        //printf("%d ",cur-m-a[i].first);
        ans = max(ans,cur-m-a[i].first);
        m = min(m,cur-a[i+1].first);


    }
    printf("%lld",ans);
}

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

art.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
art.cpp: In function 'int main()':
art.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
art.cpp:10:14: 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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...