답안 #462368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
462368 2021-08-10T12:26:25 Z Khizri 쌀 창고 (IOI11_ricehub) C++17
100 / 100
16 ms 2508 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 l=0;
	int ans=0;
	for(int i=0;i<n;i++){
		while(cal(l,i,arr)>k){
			l++;
		}
		ans=max(ans,i-l+1);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 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 1 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 0 ms 304 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 0 ms 204 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 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 204 KB Output is correct
22 Correct 1 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 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 300 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 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 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 292 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 308 KB Output is correct
19 Correct 1 ms 300 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 588 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
3 Correct 15 ms 2488 KB Output is correct
4 Correct 14 ms 2488 KB Output is correct
5 Correct 7 ms 1208 KB Output is correct
6 Correct 6 ms 1228 KB Output is correct
7 Correct 13 ms 2196 KB Output is correct
8 Correct 13 ms 2196 KB Output is correct
9 Correct 6 ms 1100 KB Output is correct
10 Correct 6 ms 1100 KB Output is correct
11 Correct 15 ms 2508 KB Output is correct
12 Correct 14 ms 2508 KB Output is correct
13 Correct 7 ms 1228 KB Output is correct
14 Correct 7 ms 1228 KB Output is correct
15 Correct 11 ms 1876 KB Output is correct
16 Correct 11 ms 1868 KB Output is correct
17 Correct 13 ms 2252 KB Output is correct
18 Correct 13 ms 2220 KB Output is correct
19 Correct 16 ms 2348 KB Output is correct
20 Correct 14 ms 2348 KB Output is correct