답안 #898763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898763 2024-01-05T05:34:48 Z Sir_Ahmed_Imran 쌀 창고 (IOI11_ricehub) C++17
100 / 100
14 ms 4564 KB
                              ///~~~LOTA~~~///
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 100000
ll a[MAXN];
ll b[MAXN];
bool check(ll n,ll l,ll r,vector<ll>& v,ll x){
    if(l==r) return 1;
    int mid=(l+r)/2;
    ll o=a[mid]+b[mid];
    o-=a[l]+(v[mid]-v[l])*l;
    o-=b[r-1]+(v[r-1]-v[mid])*(n-r);
    if(o>x) return 0;
    return 1;
}
int besthub(int N,int m,int X[],ll x){
    ll n=N;
    ll o,p,q;
    vector<ll> v;
    for(int i=0;i<n;i++)
        v.append(X[i]);
    a[0]=b[n-1]=o=p=q=0;
    for(ll i=1;i<n;i++)
        a[i]=a[i-1]+i*(v[i]-v[i-1]);
    for(ll i=n-2;i>=0;i--)
        b[i]=b[i+1]+(n-1-i)*(v[i+1]-v[i]);
    while(q<=n){
        if(check(n,p,q,v,x)){
            o=max(o,q-p);
            q++;
        }
        else p++;
    }
    return o;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2648 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2408 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2492 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2460 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2476 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2776 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 10 ms 3540 KB Output is correct
4 Correct 10 ms 3540 KB Output is correct
5 Correct 5 ms 3032 KB Output is correct
6 Correct 5 ms 3128 KB Output is correct
7 Correct 11 ms 3540 KB Output is correct
8 Correct 10 ms 3636 KB Output is correct
9 Correct 5 ms 3028 KB Output is correct
10 Correct 8 ms 3032 KB Output is correct
11 Correct 10 ms 3540 KB Output is correct
12 Correct 14 ms 3536 KB Output is correct
13 Correct 5 ms 3032 KB Output is correct
14 Correct 5 ms 3496 KB Output is correct
15 Correct 8 ms 4308 KB Output is correct
16 Correct 8 ms 4256 KB Output is correct
17 Correct 10 ms 4520 KB Output is correct
18 Correct 10 ms 4512 KB Output is correct
19 Correct 10 ms 4560 KB Output is correct
20 Correct 10 ms 4564 KB Output is correct