답안 #1027806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027806 2024-07-19T10:10:52 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
17 / 100
1000 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;
int besthub(int n, int L, int x[], long long b)
{
    int l=0, r=n-1;
    while(r-l>1)
    {
        int mid=(r+l)/2;
        long long min_dist=LLONG_MAX;
        for(int i=0; i<=n-mid-1; i++)
        {
            int polovina=(i+i+mid)/2, kraj=i+mid;
            long long dist=0;
            for(int j=i; j<polovina; j++)
            {
                dist+=abs(x[j]-x[polovina]);
            }
            for(int j=polovina+1; j<=kraj; j++)
            {
                dist+=abs(x[j]-x[polovina]);
            }
            min_dist=min(dist, min_dist);
        }
        if(min_dist<=b)
        {
            l=mid;
        }
        else
        {
            r=mid;
        }
    }
    return r;
}

/*int main()
{
    int r, l;
    long long b;
    cin>>r>>l;
    int x[r];
    for(int i=0; i<r; i++)
        cin>>x[i];
    cin>>b;
    cout<<besthub(r, l, x, b);

    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 604 KB Output is correct
2 Correct 195 ms 648 KB Output is correct
3 Execution timed out 1069 ms 1884 KB Time limit exceeded
4 Halted 0 ms 0 KB -