답안 #1115363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115363 2024-11-20T11:31:25 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
4 ms 4176 KB
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

const int MAX=5*1e5+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;

    ll a, b;
    vector<pair<ll, ll>> prace;

    for (int i=0; i<n; i++){
        cin >> a >> b;
        prace.push_back({a, b});
    }

    sort(prace.begin(), prace.end());

    ll pref[MAX];

    pref[0] = 0;
    pref[1] = prace[0].second;

    for (int i=2; i<=n; i++) pref[i] = pref[i-1] + prace[i-1].second-(prace[i-1].first-prace[i-2].first);

    ll wyn=0, mmin=pref[0];

    for (int i=1; i<=n; i++){
        //cout << pref[i] << " " << mmin << endl;
        mmin = min(mmin, pref[i]);
        wyn = max(wyn, pref[i]-mmin);
    }

    for (int i=0; i<n; i++) wyn=max(wyn, prace[i].second);
    
    cout << wyn << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Incorrect 4 ms 4176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Incorrect 4 ms 4176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Incorrect 4 ms 4176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Incorrect 4 ms 4176 KB Output isn't correct
3 Halted 0 ms 0 KB -