Submission #302644

# Submission time Handle Problem Language Result Execution time Memory
302644 2020-09-19T01:11:20 Z errorgorn Rice Hub (IOI11_ricehub) C++17
100 / 100
20 ms 1792 KB
#include "ricehub.h"

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

int besthub(int n, int L, int arr[], long long k){
	int m=0,r=-1;
	
	ll curr=0;
	
	int ans=0;
	rep(l,0,n){
		if (m<l+r>>1){
			curr-=(arr[m+1]-arr[m])*((r-m)-(m-l+1));
			m++;
		}
		
		//cout<<l<<" "<<m<<" "<<r<<" "<<curr<<endl;
		
		while (curr<=k){
			ans=max(ans,r-l+1);
			if (r==n-1) break;
			r++;
			curr+=arr[r]-arr[m];
			if (m<l+r>>1){
				curr-=(arr[m+1]-arr[m])*((r-m)-(m-l+1));
				m++;
			}
		}
		
		curr-=arr[m]-arr[l];
	}
	
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:22:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |   if (m<l+r>>1){
      |         ~^~
ricehub.cpp:34:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |    if (m<l+r>>1){
      |          ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 19 ms 1408 KB Output is correct
4 Correct 17 ms 1408 KB Output is correct
5 Correct 7 ms 896 KB Output is correct
6 Correct 7 ms 896 KB Output is correct
7 Correct 14 ms 1536 KB Output is correct
8 Correct 14 ms 1536 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 6 ms 768 KB Output is correct
11 Correct 17 ms 1792 KB Output is correct
12 Correct 20 ms 1792 KB Output is correct
13 Correct 8 ms 896 KB Output is correct
14 Correct 8 ms 896 KB Output is correct
15 Correct 13 ms 1408 KB Output is correct
16 Correct 14 ms 1536 KB Output is correct
17 Correct 19 ms 1664 KB Output is correct
18 Correct 16 ms 1664 KB Output is correct
19 Correct 17 ms 1664 KB Output is correct
20 Correct 18 ms 1664 KB Output is correct