답안 #1107642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107642 2024-11-01T19:09:37 Z Lincito_31 쌀 창고 (IOI11_ricehub) C++17
100 / 100
16 ms 4604 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int besthub(int R, int L, int X[], long long B)
{
  vll psum(R+1);
  psum[0]=0;
  psum[1]=X[0];
  for(int i=2;i<=R;i++){
    psum[i]=psum[i-1]+X[i-1];
  }
  int iz=0,de=0;
  int can=1;
  bool xd=false;
  while(iz<R && !xd){
    de=max(de,iz);
    int mid=(iz+de)/2;
    ll sum=(ll)((ll)X[mid]*(mid-iz)-(ll)(psum[mid]-psum[iz]));
    sum+=(ll)((ll)psum[de+1]-(ll)psum[mid+1]-(ll)X[mid]*(de-mid));
    while(sum<=B){
      de++;
      if(de>=R){
        xd=true;
        break;
      }
      mid=(iz+de)/2;
      sum=(ll)((ll)X[mid]*(mid-iz)-(ll)(psum[mid]-psum[iz]));
      sum+=(ll)((ll)psum[de+1]-(ll)psum[mid+1]-(ll)X[mid]*(de-mid));
    }
    can=max(can,de-iz);
    //cout << iz << " " << de << endl;
    iz++;
  }
  return can;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 488 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 388 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 10 ms 3408 KB Output is correct
4 Correct 9 ms 3408 KB Output is correct
5 Correct 5 ms 3388 KB Output is correct
6 Correct 5 ms 3392 KB Output is correct
7 Correct 9 ms 4176 KB Output is correct
8 Correct 9 ms 4176 KB Output is correct
9 Correct 4 ms 3152 KB Output is correct
10 Correct 6 ms 3292 KB Output is correct
11 Correct 10 ms 4604 KB Output is correct
12 Correct 11 ms 4432 KB Output is correct
13 Correct 5 ms 3408 KB Output is correct
14 Correct 6 ms 3408 KB Output is correct
15 Correct 8 ms 3896 KB Output is correct
16 Correct 9 ms 3920 KB Output is correct
17 Correct 9 ms 4176 KB Output is correct
18 Correct 9 ms 4176 KB Output is correct
19 Correct 13 ms 4176 KB Output is correct
20 Correct 16 ms 4176 KB Output is correct