Submission #906494

# Submission time Handle Problem Language Result Execution time Memory
906494 2024-01-14T11:02:35 Z Mathias Rice Hub (IOI11_ricehub) C++14
100 / 100
14 ms 3676 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e5+7;
ll t[MAXN], prefix[MAXN];
ll ra,rb,sa,sb,j,m,s;
bool f(int x, long long B,int R){
  for(int i=0;i<=R-x;i++){
      j=i+x-1;
      m=(i+j)/2;
      if(i) sb=prefix[m-1]-prefix[i-1];
      else sb=prefix[m-1];
      sa=prefix[j]-prefix[m];
      rb=t[m]*(m-i)-sb;
      ra=sa-t[m]*(j-m);
       if(ra+rb<=B) return true;
  }
  return false;
}
int besthub(int R, int L, int X[], long long B){
    int p=0,k=R;
    prefix[0]=X[0];
    t[0]=X[0];
    for(int i=1;i<R;i++){
      t[i]=X[i];
      prefix[i]=prefix[i-1]+X[i];
    }
    while(p<k){
        s=(p+k+1)/2;
        //cout<<p<<' '<<s<<' '<<k<<'\n';
        if(f(s,B,R)){
            p=s;
        }
        else k=s-1;
    }
    return p;
}/*
int main(){
    int n1,n2,b;
    int X[100];
    cin>>n1>>n2;
    for(int i=0;i<n1;i++) cin>>X[i];
    cin>>b;
    cout<<besthub(n1,n2,X,b)<<'\n';
}*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 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
# Verdict Execution time Memory 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 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2488 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 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 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 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 2396 KB Output is correct
25 Correct 1 ms 2396 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 2488 KB Output is correct
# Verdict Execution time Memory 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 2648 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2496 KB Output is correct
13 Correct 1 ms 2500 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 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 2492 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 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 2504 KB Output is correct
26 Correct 1 ms 2756 KB Output is correct
27 Correct 1 ms 2504 KB Output is correct
28 Correct 1 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2648 KB Output is correct
2 Correct 4 ms 2648 KB Output is correct
3 Correct 14 ms 3672 KB Output is correct
4 Correct 10 ms 3628 KB Output is correct
5 Correct 6 ms 2992 KB Output is correct
6 Correct 6 ms 2908 KB Output is correct
7 Correct 9 ms 3420 KB Output is correct
8 Correct 11 ms 3264 KB Output is correct
9 Correct 5 ms 2908 KB Output is correct
10 Correct 6 ms 2908 KB Output is correct
11 Correct 10 ms 3676 KB Output is correct
12 Correct 10 ms 3672 KB Output is correct
13 Correct 6 ms 2904 KB Output is correct
14 Correct 6 ms 2908 KB Output is correct
15 Correct 11 ms 3420 KB Output is correct
16 Correct 8 ms 3420 KB Output is correct
17 Correct 9 ms 3420 KB Output is correct
18 Correct 9 ms 3548 KB Output is correct
19 Correct 10 ms 3500 KB Output is correct
20 Correct 10 ms 3676 KB Output is correct