답안 #655654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655654 2022-11-05T05:50:26 Z Trumling 쌀 창고 (IOI11_ricehub) C++14
100 / 100
14 ms 724 KB
#include "ricehub.h"
#include<iostream>
#include<cmath>
using namespace std;
 
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
 
int besthub(int R, int L, int X[], long long B)
{
ll ans=1;
ll plus,l,r;
l=1;
r=R;
bool ok=false;
while(l<r)
{

ok=false;
plus=(l+r)/2+(l+r)%2;
bool pre=false;
ll curr=0;

for(int i=0;i<=R-plus;i++)
{
ll med;
if(!pre)
{
med=(i+i+plus-1)/2;
for(int j=i;j<i+plus;j++)
    curr+=abs(X[med]-X[j]);
 
pre=true;
}
else
{
    med++;
    ll dif=abs(X[med]-X[med-1]);
    curr+=abs(i-med)*dif;
    curr-=(plus-abs(i-med-1))*dif;
    curr+=abs(X[med]-X[i+plus-1]);
    curr-=abs(X[med-1]-X[i-1]);
}

if(curr<=B)
{
    ans=max(plus,ans);
    ok=true;
    break;
}

}
if(plus==l || plus==r)
break;
if(ok)
  l=plus;
else
  r=plus;
}
//cout<<'\n'<<ans<<'\n';
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 1 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 1 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 1 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 1 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 0 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 0 ms 212 KB Output is correct
22 Correct 1 ms 356 KB Output is correct
23 Correct 1 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 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 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 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 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 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 0 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 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 212 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 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 13 ms 596 KB Output is correct
4 Correct 12 ms 596 KB Output is correct
5 Correct 7 ms 468 KB Output is correct
6 Correct 8 ms 468 KB Output is correct
7 Correct 10 ms 596 KB Output is correct
8 Correct 14 ms 688 KB Output is correct
9 Correct 9 ms 468 KB Output is correct
10 Correct 8 ms 468 KB Output is correct
11 Correct 12 ms 676 KB Output is correct
12 Correct 11 ms 724 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 7 ms 468 KB Output is correct
15 Correct 9 ms 596 KB Output is correct
16 Correct 10 ms 596 KB Output is correct
17 Correct 10 ms 596 KB Output is correct
18 Correct 11 ms 660 KB Output is correct
19 Correct 12 ms 640 KB Output is correct
20 Correct 11 ms 596 KB Output is correct