Submission #504026

# Submission time Handle Problem Language Result Execution time Memory
504026 2022-01-09T14:27:21 Z Newtech66 Rice Hub (IOI11_ricehub) C++17
42 / 100
16 ms 2476 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;
        chk+=max(0,pos-i+1)*query(pos,pos)-query(i,pos);
        chk+=query(pos+1,i+k-1)-max(0,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;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 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 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 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 1 ms 204 KB Output is correct
22 Correct 0 ms 304 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 304 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 224 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 0 ms 204 KB Output is correct
13 Correct 0 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 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Incorrect 1 ms 312 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 624 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 16 ms 2476 KB Output is correct
4 Incorrect 16 ms 2428 KB Output isn't correct
5 Halted 0 ms 0 KB -