답안 #919087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919087 2024-01-31T08:25:09 Z Aiperiii 쌀 창고 (IOI11_ricehub) C++14
100 / 100
12 ms 6204 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
   vector <long long> v;
   for(int i=0;i<R;i++)v.pb(X[i]);
   vector <long long> sum;long long x=0;
   for(int i=0;i<R;i++){
      x+=v[i];sum.pb(x);
   }
   int l=0,r=R+2;
   while(l+1<r){
      int md=(l+r)/2;
      bool ok=0;
      for(int i=0;i<R;i++){
         long long x=0;
         long long a=0,b=0;
         if(md%2==1){a=md/2;b=md/2;}
         else {a=md/2;b=md/2-1;}
         if(i>a-1 && i+b<R){
            long long pos=i-1;
            long long d=0;
            if(pos>=0)d+=sum[pos];
            if(pos-a>=0)d-=sum[pos-a];
            x+=v[i]*a-d;
            pos=i+b;
            d=sum[pos]-sum[i];
            x+=d-v[i]*b;
            if(x<=B)ok=1;
         }
      }
      if(ok)l=md;
      else r=md;
   }
   return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 500 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 856 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 3 ms 980 KB Output is correct
3 Correct 11 ms 4816 KB Output is correct
4 Correct 11 ms 4812 KB Output is correct
5 Correct 6 ms 3792 KB Output is correct
6 Correct 7 ms 3792 KB Output is correct
7 Correct 10 ms 4968 KB Output is correct
8 Correct 10 ms 4812 KB Output is correct
9 Correct 6 ms 3792 KB Output is correct
10 Correct 6 ms 3792 KB Output is correct
11 Correct 12 ms 4816 KB Output is correct
12 Correct 12 ms 4816 KB Output is correct
13 Correct 7 ms 3792 KB Output is correct
14 Correct 7 ms 4048 KB Output is correct
15 Correct 10 ms 5580 KB Output is correct
16 Correct 10 ms 5572 KB Output is correct
17 Correct 11 ms 5836 KB Output is correct
18 Correct 10 ms 5692 KB Output is correct
19 Correct 11 ms 5836 KB Output is correct
20 Correct 12 ms 6204 KB Output is correct