답안 #530545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530545 2022-02-25T19:09:11 Z Jesus 쌀 창고 (IOI11_ricehub) C++14
100 / 100
14 ms 1716 KB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    long long int precio=0,maximo=0;
    int izq=0,der=0,cen=0;
    int i=0,j=0;
    int aux;
    while(i<R){
        if(j==R-1||precio>B){
            if(precio<=B) maximo=max((long long int)j-i+1,maximo);
            precio-=(X[cen]-X[i]);
            i++;
            aux=(i+j)/2;
            if(aux>cen){
                precio+=(X[aux]-X[cen])*(cen-i);
                precio-=(X[aux]-X[cen])*(j-aux);
                cen=aux;
            }
        }
        else{
            maximo=max(maximo,(long long int)(j-i)+1);
            j++;
            aux=(j+i)/2;
            precio+=X[j]-X[aux];
            if(aux>cen){
                precio+=(X[aux]-X[cen])*(cen-i);
                precio-=(X[aux]-X[cen])*(j-aux-1);
                cen=aux;
            }
        }
    }
    return maximo;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:9: warning: unused variable 'izq' [-Wunused-variable]
    9 |     int izq=0,der=0,cen=0;
      |         ^~~
ricehub.cpp:9:15: warning: unused variable 'der' [-Wunused-variable]
    9 |     int izq=0,der=0,cen=0;
      |               ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 308 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 304 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 204 KB Output is correct
4 Correct 0 ms 304 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 0 ms 204 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 220 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 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 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 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 308 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 1 ms 204 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 316 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 440 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 12 ms 1704 KB Output is correct
4 Correct 12 ms 1716 KB Output is correct
5 Correct 5 ms 824 KB Output is correct
6 Correct 5 ms 824 KB Output is correct
7 Correct 10 ms 1416 KB Output is correct
8 Correct 10 ms 1376 KB Output is correct
9 Correct 7 ms 708 KB Output is correct
10 Correct 5 ms 684 KB Output is correct
11 Correct 11 ms 1716 KB Output is correct
12 Correct 12 ms 1644 KB Output is correct
13 Correct 6 ms 836 KB Output is correct
14 Correct 6 ms 844 KB Output is correct
15 Correct 9 ms 1348 KB Output is correct
16 Correct 9 ms 1368 KB Output is correct
17 Correct 11 ms 1576 KB Output is correct
18 Correct 11 ms 1480 KB Output is correct
19 Correct 14 ms 1624 KB Output is correct
20 Correct 11 ms 1588 KB Output is correct