답안 #185431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
185431 2020-01-11T16:19:07 Z awlintqaa 쌀 창고 (IOI11_ricehub) C++14
100 / 100
22 ms 3348 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 500
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;//998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
#include "ricehub.h"
ll n,k;
ll a[100009],sum[100009];
ll check2(ll l,ll r){
        ll x=a[mid];
        ll num1=mid-l;
        ll num2=r-mid;
        ll sum1=0;
        if(mid)sum1+=sum[mid-1];
        if(l)sum1-=sum[l-1];
        ll sum2=sum[r]-sum[mid];
        ll all=((num1*x)-sum1)+(sum2-(num2*x));
        return (all<=k);
}
ll check1(ll x){
        ll L=0,R=x-1;
        if(check2(L,R))return 1;
        for(ll i=x;i<n;i++){
                L++,R++;
                if(check2(L,R))return 1;
        }
        return 0;
}
int besthub(int R, int L, int X[], long long B){
        n=R,k=B;
        for(ll i=0;i<n;i++)a[i]=X[i];
        sort(a,a+n);
        for(ll i=0;i<n;i++){
                sum[i]=a[i];
                if(i)sum[i]+=sum[i-1];
        }
        ll l=1,r=n+1;
        while(r-l>1){
                if(check1(mid))l=mid;
                else r=mid;
        }
        return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 0 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 252 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 0 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 888 KB Output is correct
2 Correct 6 ms 860 KB Output is correct
3 Correct 20 ms 3192 KB Output is correct
4 Correct 21 ms 3348 KB Output is correct
5 Correct 12 ms 1656 KB Output is correct
6 Correct 12 ms 1656 KB Output is correct
7 Correct 18 ms 3064 KB Output is correct
8 Correct 17 ms 3192 KB Output is correct
9 Correct 11 ms 1624 KB Output is correct
10 Correct 12 ms 1656 KB Output is correct
11 Correct 22 ms 3320 KB Output is correct
12 Correct 22 ms 3320 KB Output is correct
13 Correct 15 ms 1784 KB Output is correct
14 Correct 13 ms 1784 KB Output is correct
15 Correct 17 ms 2552 KB Output is correct
16 Correct 17 ms 2552 KB Output is correct
17 Correct 20 ms 3064 KB Output is correct
18 Correct 20 ms 3064 KB Output is correct
19 Correct 21 ms 3192 KB Output is correct
20 Correct 21 ms 3188 KB Output is correct