답안 #77123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77123 2018-09-22T13:49:12 Z Vardanyan Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 500*1000+7;
pair<long long,long long> a[N];
long long pref[N];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
            scanf("%lld%lld",&a[i].first,&a[i].second);
    }
    sort(a+1,a+1+n);
    long long ans = 0;
    long long mxdif = -1000000000000005;
    long long s = 0;
    for(int i = 1;i<=n;i++){
        pref[i] = pref[i-1]+a[i].second;
        s+=a[i].second;
        long long u = s-(a[i].first-a[1].first);
        ans = max(ans,u);
        u+=mxdif;
        ans = max(ans,u);
        mxdif = max(mxdif,(a[i].first-a[1].first)-pref[i-1]);
        //cout<<mxdif<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
art.cpp:10:18: 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);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -