답안 #966863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966863 2024-04-20T13:58:00 Z vjudge1 Art Exhibition (JOI18_art) C++11
0 / 100
1 ms 2648 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fi first
#define se second

ll N;
pll arr[500100];
ll psum[500100];
ll ans=0, maks=0;


int main() 
{
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> arr[i].fi >> arr[i].se;
    }
    sort(arr+1, arr+N+1);
    for(int i=1; i<=N; i++) {
        psum[i] = psum[i-1] + arr[i].se;
    }
    for(int i=N; i>=1; i--) {
        maks = max(maks, psum[i]-arr[i].fi);
        ans = max(ans, maks + arr[i].fi-psum[i-1]);
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -