답안 #655217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655217 2022-11-03T14:53:05 Z Trumling 쌀 창고 (IOI11_ricehub) C++14
0 / 100
98 ms 604 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)
{
  bool arr[L+1]={ };
for(int i=0;i<R;i++)
{
    arr[X[i]]=true;
}
ll ans=1;
ll count=0;
ll plus=R;
while(plus!=1)
{
if(ans!=1)
break;
bool pre=false;
ll curr=0;
cout<<'\n';
for(int i=0;i<=R-plus;i++)
{
ll med;
if(!pre)
{
med=(i+i+plus)/2;
for(int j=i;j<i+plus;j++)
    curr+=abs(X[med]-X[j]);

pre=true;
}
else
{
    curr-=abs(X[i-1]-X[med]);
    med++;
    ll dif=abs(X[med]-X[med-1]);
    curr=curr+abs(i-med)*dif;
    curr=curr-(plus-med)*dif;
    curr+=(X[med]-X[i+plus-1]);

}

//cout<<curr<<' ';



if(curr<=B)
{
    ans=plus;
    break;
}
}
plus--;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:20:4: warning: unused variable 'count' [-Wunused-variable]
   20 | ll count=0;
      |    ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 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 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 98 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -