답안 #1100324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100324 2024-10-13T13:45:38 Z mm77 쌀 창고 (IOI11_ricehub) C++14
100 / 100
14 ms 3684 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+3;
long long r,l,b,x[N];
bool ok(int mid)
{
    long long left=0,right=mid-1,sr=(left+right)/2,res=0;
    for(int i=left;i<=right;i++)
    {
        res+=abs(x[i]-x[sr]);
    }
    while(right<r)
    {
        if(res<=b)return true;
        res+=(sr-left+1)*(x[sr+1]-x[sr]);
        res-=(right-sr)*(x[sr+1]-x[sr]);
        res-=x[sr+1]-x[left];
        res+=x[right+1]-x[sr+1];
        sr++,right++,left++;
    }
    return false;
}
int besthub(int r2,int l2,int x2[],long long b2)
{
    r=r2,l=l2,b=b2;
    for(int i=0;i<r;i++)x[i]=x2[i];
    int pocz=1,kon=r+1;
    while(pocz+1<kon)
    {
        int mid=(pocz+kon)/2;
        if(ok(mid))pocz=mid;
        else kon=mid;
    }
    return pocz;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 1 ms 2552 KB Output is correct
3 Correct 1 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 1 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 1 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 1 ms 2388 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 1 ms 2388 KB Output is correct
13 Correct 1 ms 2388 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 1 ms 2388 KB Output is correct
16 Correct 1 ms 2388 KB Output is correct
17 Correct 1 ms 2556 KB Output is correct
18 Correct 1 ms 2388 KB Output is correct
19 Correct 1 ms 2388 KB Output is correct
20 Correct 1 ms 2552 KB Output is correct
21 Correct 1 ms 2552 KB Output is correct
22 Correct 1 ms 2388 KB Output is correct
23 Correct 1 ms 2388 KB Output is correct
24 Correct 1 ms 2388 KB Output is correct
25 Correct 1 ms 2388 KB Output is correct
26 Correct 1 ms 2388 KB Output is correct
27 Correct 1 ms 2504 KB Output is correct
28 Correct 1 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 1 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 1 ms 2388 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 1 ms 2388 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2388 KB Output is correct
11 Correct 1 ms 2496 KB Output is correct
12 Correct 1 ms 2388 KB Output is correct
13 Correct 1 ms 2496 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 1 ms 2388 KB Output is correct
16 Correct 1 ms 2388 KB Output is correct
17 Correct 1 ms 2388 KB Output is correct
18 Correct 1 ms 2388 KB Output is correct
19 Correct 1 ms 2552 KB Output is correct
20 Correct 1 ms 2388 KB Output is correct
21 Correct 2 ms 2388 KB Output is correct
22 Correct 1 ms 2388 KB Output is correct
23 Correct 1 ms 2388 KB Output is correct
24 Correct 2 ms 2388 KB Output is correct
25 Correct 2 ms 2556 KB Output is correct
26 Correct 1 ms 2388 KB Output is correct
27 Correct 1 ms 2388 KB Output is correct
28 Correct 1 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2644 KB Output is correct
2 Correct 3 ms 2644 KB Output is correct
3 Correct 14 ms 3684 KB Output is correct
4 Correct 11 ms 3684 KB Output is correct
5 Correct 5 ms 2900 KB Output is correct
6 Correct 5 ms 2900 KB Output is correct
7 Correct 9 ms 3412 KB Output is correct
8 Correct 9 ms 3412 KB Output is correct
9 Correct 5 ms 2900 KB Output is correct
10 Correct 6 ms 2784 KB Output is correct
11 Correct 10 ms 3532 KB Output is correct
12 Correct 11 ms 3680 KB Output is correct
13 Correct 5 ms 2900 KB Output is correct
14 Correct 5 ms 2916 KB Output is correct
15 Correct 8 ms 3276 KB Output is correct
16 Correct 7 ms 3372 KB Output is correct
17 Correct 9 ms 3412 KB Output is correct
18 Correct 9 ms 3532 KB Output is correct
19 Correct 9 ms 3668 KB Output is correct
20 Correct 9 ms 3668 KB Output is correct