답안 #43662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43662 2018-03-19T07:39:18 Z smu201111192 쌀 창고 (IOI11_ricehub) C++14
0 / 100
5 ms 1244 KB
#include "ricehub.h"
#include <iostream>
#include <cstdio>
#include <cassert>
#include <bitset>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN = 400005;
long long sum[MAXN];
long long loc[MAXN];
int n;
int can(int mid,long long lim){
    //mid개를 제거하면 가능한지
    for(int L = 0; L <= mid; L++){
        int R = mid - L;
        int lpos = L + 1;
        int rpos = n - R;
        int mpos = (lpos+rpos)/2;
        long long tot = 0;
        long long lcnt = mpos - lpos + 1;
        long long rcnt = rpos - mpos;
        long long lsum = sum[mpos] - sum[lpos-1];
        long long rsum = sum[n] - sum[mpos];
        tot = (lcnt * mpos) - (lsum) + (rsum) - (rcnt * mpos);
        if(tot <= lim){
            return 1;
        }
    }
    return 0;
}
int besthub(int R, int L, int X[], long long B)
{
    n = R;
    for(int i=0; i<R; i++) loc[i+1] = X[i];
    for(int i=1;i<=R;i++){
        sum[i] += sum[i-1] + loc[i];
    }
    int low = 0;
    int high = R;
    while(low<=high){
        int mid = (low+high)/2;
        if(can(mid,B)){
            high = mid - 1;
        }
        else low = mid + 1;
    }
    return n-(high + 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Incorrect 2 ms 484 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 560 KB Output is correct
2 Correct 2 ms 560 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 1 ms 628 KB Output is correct
5 Incorrect 2 ms 768 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1244 KB Output isn't correct
2 Halted 0 ms 0 KB -