답안 #552016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552016 2022-04-22T08:12:44 Z ala2 쌀 창고 (IOI11_ricehub) C++14
68 / 100
14 ms 2500 KB
 //   #include "ricehub.h"
    #include <iostream>
    using namespace std;
    int n,d;
    int a[1000100];
    int b;
    int P[1001000];
    int f(int i,int j)
    {
        int x=(i+j)/2;
        int ta=j-i+1;
        int one=P[x]-P[i]+a[i]-a[x];
        int g=0;
        int ta1=x-i;
        g=ta1*a[x]-one;
        int tow=P[j]-P[x];
        int ta2=j-x;
        g+=tow-ta2*a[x];
        return g;
    }
    int ok(int mid)
    {
        for(int i=0;i<n;i++)
        {
            if(i+mid>=n)
                break;
            if(f(i,i+mid)<=b)
            {
                return 1;
            }
        }
        return 0;
    }
    int besthub(int R, int L, int X[], long long B)
    {
        n=R;
        d=L;
        b=B;
        for(int i=0;i<n;i++)
            a[i]=X[i];
        P[0]=a[0];
        for(int i=1;i<n;i++)
          P[i]=P[i-1]+a[i];
        int mx=1;
        int l=0;
        int r=n;
        while(r-l>1)
        {
            int mid=(l+r)/2;
            if(ok(mid))
            {
                l=mid;
            }
            else r=mid;
        }

        int ann=l+1;
        //cout<<mx<<endl;
        return ann;
    }

Compilation message

ricehub.cpp: In function 'int f(int, int)':
ricehub.cpp:11:13: warning: unused variable 'ta' [-Wunused-variable]
   11 |         int ta=j-i+1;
      |             ^~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:44:13: warning: unused variable 'mx' [-Wunused-variable]
   44 |         int mx=1;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 212 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 212 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 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 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 304 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 308 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 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 2 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 6 ms 596 KB Output is correct
3 Incorrect 14 ms 2500 KB Output isn't correct
4 Halted 0 ms 0 KB -