답안 #94776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94776 2019-01-23T17:04:29 Z MvC 쌀 창고 (IOI11_ricehub) C++11
0 / 100
4 ms 764 KB
#include "ricehub.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
ll n,m,l,r,mid,i;
ll b,x[nmax],s[nmax];
int ok(int k,int md)
{
    for(int i=k;i<=n;i++)
    {
        ll tot=-1LL*(1LL*s[i-md+1]-1LL*s[i-k])+1LL*(1LL*i-1LL*md+1LL*1-1LL*i+1LL*k)*1LL*x[md]+1LL*s[i]-1LL*s[i-md+1]-1LL*(1LL*i-1LL*i+1LL*md-1LL*1)*1LL*x[md];
        if(tot<=b)return 1;
    }
    return 0;
}
int besthub(int N,int m,int y[],ll B)
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	b=B;
	n=N;
	for(i=1;i<=n;i++)
	{
	    x[i]=y[i-1];
	    s[i]=s[i-1]+x[i];
	}
	l=1,r=n;
	while(l<=r)
	{
	    mid=(l+r)/2;
	    if(ok(mid,(mid/2)+1))l=mid+1;
	    else r=mid-1;
	}
	if(ok(l-1,((l-1)/2)+1))return max(l-1,1LL);
	else return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -