답안 #860875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860875 2023-10-14T16:57:31 Z Huseyn123 쌀 창고 (IOI11_ricehub) C++17
68 / 100
21 ms 3672 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define MAX 200001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
    for(int i=0;i<b;i++){\
        cin >> a[i];\
    }\
}
#define inputvec(a,b){\
    for(int i=0;i<b;i++){\
        ll num;\
        cin >> num;\
        a.pb(num);\
    }\
}
#define outputar(a,b){\
    for(int i=0;i<b;i++){\
        cout << a[i] << " ";\
    }\
    cout << "\n";\
}
#define outputvec(a){\
    for(auto x:a){\
        cout << x << " ";\
    }\
    cout << "\n";\
}
#define reset(a,n,v){\
    for(int i=0;i<n;i++){\
        a[i]=v;\
    }\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
int Y[MAX],Y1[MAX],n;
ll b;
ll f(int h,int x,int y){
	ll res=0;
	ll h1=Y[h];
	if(x>0){
		h1-=Y[x-1];
	}
	ll h2=Y[y]-Y[h];
	res+=(h-x+1)*Y1[h]+h2-(y-h)*Y1[h]-h1;
	return res;
}
bool f1(int h,int h3){
	if(h3%2==0){
		if(h-h3/2+1>=0 && h+h3/2<n && f(h,h-h3/2+1,h+h3/2)<=b){
			//cout << h << " " << h3 << " " << 1 << "\n";
			return true;
		}
		if(h-h3/2>=0 && h+h3/2-1<n && f(h,h-h3/2,h+h3/2-1)<=b){
			//cout << h << " " << h3 << " " << 2 << "\n";
			return true;
		}
	}
	else{
		if(h-h3/2>=0 && h+h3/2<n && f(h,h-h3/2,h+h3/2)<=b){
			//cout << h << " " << h3 << " " << 3 << "\n";
			return true;
		}
	}
	return false;
}
int besthub(int R, int L, int X[], long long B)
{
	b=B;
	n=R;
	for(int i=0;i<R;i++){
		Y[i]=X[i];
		Y1[i]=X[i];
	}
	for(int i=1;i<R;i++){
		Y[i]+=Y[i-1];
	}
	int res=0;
	for(int i=0;i<R;i++){
		int l,r; 
		l=0,r=R; 
		while(l<r){
			ll mid=(l+r+1)/2;
			if(f1(i,mid)){
				l=mid;
			}
			else{
				r=mid-1;
			}
		}
		res=max(res,l);
		//cout << i << " " << l << "\n";
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 0 ms 2392 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2500 KB Output is correct
26 Correct 1 ms 2648 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2396 KB Output is correct
2 Correct 4 ms 2476 KB Output is correct
3 Correct 20 ms 2648 KB Output is correct
4 Incorrect 21 ms 3672 KB Output isn't correct
5 Halted 0 ms 0 KB -