답안 #744032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744032 2023-05-18T07:23:57 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
68 / 100
13 ms 1456 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;
 
long long 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 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
# 결과 실행 시간 메모리 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 0 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 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 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 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 312 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 11 ms 1408 KB Output is correct
4 Correct 13 ms 1420 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 9 ms 1456 KB Output is correct
8 Correct 10 ms 1356 KB Output is correct
9 Correct 6 ms 896 KB Output is correct
10 Correct 6 ms 852 KB Output is correct
11 Correct 11 ms 1364 KB Output is correct
12 Correct 11 ms 1436 KB Output is correct
13 Incorrect 5 ms 796 KB Output isn't correct
14 Halted 0 ms 0 KB -