Submission #123294

# Submission time Handle Problem Language Result Execution time Memory
123294 2019-07-01T06:07:05 Z baluteshih Rice Hub (IOI11_ricehub) C++14
100 / 100
20 ms 2552 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll sum[100005];

ll w(int l,int r)
{
	int mid=l+r>>1;
	if(l+r&1)
		return sum[r]-sum[mid]-sum[mid]+sum[l-1];
	else 
		return sum[r]-sum[mid]-sum[mid-1]+sum[l-1];
}

int besthub(int R, int L, int X[], long long B)
{
	int ans=0;
	for(int i=1;i<=R;++i)
		sum[i]=sum[i-1]+X[i-1];
	for(int i=1,j=0;i<=R;++i)
	{
		while(j<R&&w(i,j+1)<=B) ++j;
		ans=max(ans,j-i+1);
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'll w(int, int)':
ricehub.cpp:21:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=l+r>>1;
          ~^~
ricehub.cpp:22:6: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
  if(l+r&1)
     ~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory 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 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 252 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 2 ms 248 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 760 KB Output is correct
3 Correct 18 ms 2552 KB Output is correct
4 Correct 18 ms 2552 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 9 ms 1272 KB Output is correct
7 Correct 16 ms 2268 KB Output is correct
8 Correct 16 ms 2216 KB Output is correct
9 Correct 9 ms 1400 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 20 ms 2552 KB Output is correct
12 Correct 20 ms 2552 KB Output is correct
13 Correct 9 ms 1272 KB Output is correct
14 Correct 10 ms 1272 KB Output is correct
15 Correct 15 ms 2040 KB Output is correct
16 Correct 15 ms 2044 KB Output is correct
17 Correct 18 ms 2296 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 19 ms 2424 KB Output is correct
20 Correct 19 ms 2552 KB Output is correct