답안 #48932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48932 2018-05-20T05:32:06 Z faishol27 Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define PUB push_back

struct art{
    ll sz, val;
};

int N;
ll pref[500005], ans = 0;
vector<art> data;

ll sliding_window(int len){
    ll ret = 0;

    for(int i=1;i+len-1<=N;i++){
        ll tmp = (pref[i+len-1]-pref[i-1])-(data[i+len-1].sz-data[i].sz);
        ret = max(ret, tmp);
    }

    return ret;
}

bool comp(art a, art b){
    if(a.sz == b.sz) return a.val < b.val;
    return a.sz < b.sz;
}

int main(){
    cin >> N;
    data.PUB({0,0});
    for(int i=1;i<=N;i++){
        ll a, b;
        cin >> a >> b;
        data.PUB({a, b});
    }

    sort(data.begin(), data.end(), comp);

    for(int i=1;i<=N;i++) pref[i] = pref[i-1]+data[i].val;
    
    int l=1, r=N;
    while(l<=r){
        int m = (l+r)/2;
        ll tmp = sliding_window(m);

        if(tmp > ans) l = m+1;
        else r = m-1;

        ans = max(tmp, ans);
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 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 -