Submission #744023

# Submission time Handle Problem Language Result Execution time Memory
744023 2023-05-18T07:19:31 Z Sainen420 Rice Hub (IOI11_ricehub) C++17
68 / 100
12 ms 2108 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;

int qs[100005]={};
int ans=0;

int besthub(int R, int L, int X[], long long B)
{
  for(int i=1;i<=R;i++){
        qs[i]=qs[i-1]+X[i-1];
    }
    int l=1,r=R;
    long long cost;
    while(l<=r){
        int len=(r+l)>>1;
        bool v =false;
        //iterate start points
        //S=i,E=i+len-1,N=(s+e)/2
        int S,E,N;
        //cout << len << '=';
        for(int i=1;i<=(R-len+1);i++){
            S=i,E=i+len-1,N=(S+E+1)/2;
            cost = (X[N-1]*(N-1-S)) - qs[N-1] + qs[S-1] + qs[E] - qs[N] - ((E-N-1)*X[N-1]);
            //cout << cost << ' ';
            if(cost<=B){
                v=true;
                break;
            }
        }
        //cout << endl;
        if(v){
            ans=max(len,ans);
            l=len+1;
        }else{
            r=len-1;
        }
    }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 224 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 576 KB Output is correct
3 Correct 12 ms 2108 KB Output is correct
4 Incorrect 12 ms 2092 KB Output isn't correct
5 Halted 0 ms 0 KB -