Submission #43664

# Submission time Handle Problem Language Result Execution time Memory
43664 2018-03-19T07:51:24 Z smu201111192 Rice Hub (IOI11_ricehub) C++14
100 / 100
29 ms 8776 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[rpos] - sum[mpos];
        tot = (lcnt * loc[mpos]) - (lsum) + (rsum) - (rcnt * loc[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);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 608 KB Output is correct
2 Correct 1 ms 612 KB Output is correct
3 Correct 2 ms 612 KB Output is correct
4 Correct 1 ms 680 KB Output is correct
5 Correct 1 ms 680 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 1 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 1 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 1 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 1 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 808 KB Output is correct
22 Correct 1 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 2 ms 808 KB Output is correct
26 Correct 2 ms 808 KB Output is correct
27 Correct 1 ms 808 KB Output is correct
28 Correct 2 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 808 KB Output is correct
2 Correct 2 ms 808 KB Output is correct
3 Correct 2 ms 808 KB Output is correct
4 Correct 2 ms 808 KB Output is correct
5 Correct 2 ms 808 KB Output is correct
6 Correct 1 ms 808 KB Output is correct
7 Correct 2 ms 808 KB Output is correct
8 Correct 2 ms 808 KB Output is correct
9 Correct 2 ms 808 KB Output is correct
10 Correct 2 ms 808 KB Output is correct
11 Correct 2 ms 808 KB Output is correct
12 Correct 2 ms 808 KB Output is correct
13 Correct 1 ms 808 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 892 KB Output is correct
22 Correct 3 ms 1040 KB Output is correct
23 Correct 3 ms 1040 KB Output is correct
24 Correct 2 ms 1040 KB Output is correct
25 Correct 2 ms 1072 KB Output is correct
26 Correct 3 ms 1220 KB Output is correct
27 Correct 2 ms 1220 KB Output is correct
28 Correct 2 ms 1220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1488 KB Output is correct
2 Correct 5 ms 1488 KB Output is correct
3 Correct 18 ms 3152 KB Output is correct
4 Correct 18 ms 3152 KB Output is correct
5 Correct 10 ms 3152 KB Output is correct
6 Correct 16 ms 3152 KB Output is correct
7 Correct 16 ms 3152 KB Output is correct
8 Correct 15 ms 3152 KB Output is correct
9 Correct 18 ms 3152 KB Output is correct
10 Correct 10 ms 3152 KB Output is correct
11 Correct 19 ms 3152 KB Output is correct
12 Correct 23 ms 3152 KB Output is correct
13 Correct 11 ms 3152 KB Output is correct
14 Correct 11 ms 3152 KB Output is correct
15 Correct 17 ms 3668 KB Output is correct
16 Correct 16 ms 4504 KB Output is correct
17 Correct 29 ms 5808 KB Output is correct
18 Correct 28 ms 6700 KB Output is correct
19 Correct 19 ms 7772 KB Output is correct
20 Correct 19 ms 8776 KB Output is correct