# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
655200 | Trumling | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for(int i=0;i<=R-plus;i++)
{
ll med=(i+i+plus)/2;
ll curr=0;
for(int j=i;j<i+plus;j++)
curr+=abs(X[med]-X[j]);
if(curr<=B)
{
ans=plus;
break;
}
}
plus--;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}
#include "ricehub.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_R 1000000
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
static void read_input()
{
int i;
my_assert(3==scanf("%d %d %lld",&R,&L,&B));
for(i=0; i<R; i++)
my_assert(1==scanf("%d",&X[i]));
my_assert(1==scanf("%d",&solution));
}
int main()
{
ll anse;
read_input();
anse = besthub(R,L,X,B);
if(anse==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d instead of %d.\n",anse,solution);
return 0;
}