답안 #725454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725454 2023-04-17T12:59:22 Z Mauve 쌀 창고 (IOI11_ricehub) C++14
100 / 100
14 ms 2528 KB
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
//using namespace __gnu_pbds;
using namespace std;
#include "ricehub.h"
//#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define INF 4000000000000000000
#define MOD 1000000007
#define ll long long
#define pb push_back
#define A 900000011
#define ss second
#define endl '\n'
#define ff first
ll n,m,l,r,i,ii,jj,xx,yy,j,t,x,y,z,T,k,p,ans,a[100005];
bool shaa(ll k){
    ll med=(k-1)/2,sum=0,ans;
    for(ll i=0;i<k;i++) sum+=abs(a[med]-a[i]);
    ans=sum;
    for(ll i=k;i<n;i++){
        sum-=(a[med]-a[i-k]);
        sum+=(med-(i-k))*(a[med+1]-a[med]);
        sum-=(i-1-med)*(a[med+1]-a[med]);
        med++;
        sum+=(a[i]-a[med]);
        ans=min(ans,sum);
    }
    if(ans<=p) return true;
    else return false;
}


int besthub(int R, int L, int X[], long long B)
{
	ll l=0,r=R,m;
    for(int i=0;i<R;i++) a[i]=X[i];
    n=R;
    p=B;
    while(r-l>1){
        m=(r+l)/2;
        if(shaa(m)) l=m;
        else r=m-1;
    }
    if(shaa(r)) return r;
    else return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 316 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1 ms 360 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 3 ms 636 KB Output is correct
3 Correct 14 ms 2528 KB Output is correct
4 Correct 14 ms 2492 KB Output is correct
5 Correct 9 ms 1192 KB Output is correct
6 Correct 7 ms 1224 KB Output is correct
7 Correct 12 ms 2132 KB Output is correct
8 Correct 14 ms 2144 KB Output is correct
9 Correct 7 ms 1108 KB Output is correct
10 Correct 7 ms 1076 KB Output is correct
11 Correct 14 ms 2432 KB Output is correct
12 Correct 13 ms 2488 KB Output is correct
13 Correct 7 ms 1236 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 10 ms 1876 KB Output is correct
16 Correct 10 ms 1968 KB Output is correct
17 Correct 13 ms 2228 KB Output is correct
18 Correct 12 ms 2228 KB Output is correct
19 Correct 13 ms 2380 KB Output is correct
20 Correct 13 ms 2380 KB Output is correct