답안 #655652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655652 2022-11-05T05:39:26 Z Trumling 쌀 창고 (IOI11_ricehub) C++14
0 / 100
2 ms 308 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)
{
if(plus==l || plus==r)
break;
ok=false;
plus=(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(ok)
  l=plus;
else
  r=plus;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:21:1: warning: 'plus' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 | if(plus==l || plus==r)
      | ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -