답안 #462369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
462369 2021-08-10T12:30:45 Z Khizri 쌀 창고 (IOI11_ricehub) C++17
100 / 100
28 ms 1480 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back		 
#define F first																 
#define S second 															 
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1e5+5;
ll sum[mxn];
ll f(int ind){
	if(ind<0){
		return 0;
	}
	return sum[ind];
}
ll cal(int l,int r,int arr[]){
	int m=(l+r)/2;
	ll k=0;
	k+=arr[m]*(m-l+1)-(sum[m]-f(l-1));
	k+=sum[r]-f(m-1)-arr[m]*(r-m+1);
	return k;
}
int besthub(int n, int dis, int arr[], long long k)
{
	sum[0]=arr[0];
	for(int i=1;i<n;i++){
		sum[i]=sum[i-1]+arr[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int l=i,r=n-1,ind=0;
		while(l<=r){
			int m=(l+r)/2;
			if(cal(i,m,arr)<=k){
				ind=m;
				l=m+1;
			}
			else{
				r=m-1;
			}
		}
		ans=max(ans,ind-i+1);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 452 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 20 ms 1356 KB Output is correct
4 Correct 22 ms 1388 KB Output is correct
5 Correct 12 ms 884 KB Output is correct
6 Correct 13 ms 812 KB Output is correct
7 Correct 19 ms 1360 KB Output is correct
8 Correct 20 ms 1480 KB Output is correct
9 Correct 9 ms 844 KB Output is correct
10 Correct 10 ms 892 KB Output is correct
11 Correct 21 ms 1476 KB Output is correct
12 Correct 21 ms 1464 KB Output is correct
13 Correct 10 ms 892 KB Output is correct
14 Correct 9 ms 844 KB Output is correct
15 Correct 15 ms 1068 KB Output is correct
16 Correct 15 ms 1100 KB Output is correct
17 Correct 18 ms 1320 KB Output is correct
18 Correct 19 ms 1228 KB Output is correct
19 Correct 28 ms 1320 KB Output is correct
20 Correct 19 ms 1356 KB Output is correct