답안 #504031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
504031 2022-01-09T14:31:13 Z Newtech66 쌀 창고 (IOI11_ricehub) C++17
42 / 100
13 ms 1472 KB
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
 
bool ok(const vector<lol>& p,int n,lol B,int k)
{
    auto query=[&](int l,int r){
        if(l>r) return 0ll;
        return p[r]-(l?p[l-1]:0);
    };
    for(int i=0;i+k-1<n;i++)
    {
        int pos=i+k/2;
        lol chk=0;
        if(i<=pos)  chk+=(pos-i+1)*query(pos,pos)-query(i,pos);
        if(pos+1<=i+k-1)    chk+=query(pos+1,i+k-1)-(i+k-1-pos)*query(pos,pos);
        if(chk<=B)  return true;
    }
    return false;
}
 
int besthub(int R,int L,int X[],lol B)
{
    vector<lol> p(R);
    partial_sum(X,X+R,p.begin());
    int l=1,r=R,mid,ans;
    while(l<=r)
    {
        mid=l+(r-l)/2;
        if(ok(p,R,B,mid))
        {
            ans=mid;
            l=mid+1;
        }else   r=mid-1;
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, lol)':
ricehub.cpp:36:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ans;
      |            ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Incorrect 1 ms 332 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 12 ms 1472 KB Output is correct
4 Incorrect 13 ms 1384 KB Output isn't correct
5 Halted 0 ms 0 KB -