Submission #155837

# Submission time Handle Problem Language Result Execution time Memory
155837 2019-09-30T19:58:01 Z m1sch3f Rice Hub (IOI11_ricehub) C++17
100 / 100
21 ms 2552 KB

#include <bits/stdc++.h>
using namespace std;

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

using pll = pair<ll,ll>;

int besthub(int N, int L, int d[], ll B) {
	ll X[N];
	f(i,0,N) X[i] = i?X[i-1]+d[i]:d[i];
	auto fu = [&](int i, int j) {
		int m = i+j>>1, x = X[m]-(m?X[m-1]:0);
		return 1LL*x*(2*m-i-j)-(m?X[m-1]:0)+(i?X[i-1]:0)
			+X[j]-X[m];
	};
	int ans = 0, j = 0;
	f(i,0,N) {
		re(j,i);
		while (j+1<N && fu(i,j+1) <= B)
			j++;
		re(ans,j-i+1);
	}	
	return ans;
}

Compilation message

ricehub.cpp: In lambda function:
ricehub.cpp:66:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = i+j>>1, x = X[m]-(m?X[m-1]:0);
           ~^~
# 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 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 8 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 256 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 252 KB Output is correct
# 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 256 KB Output is correct
4 Correct 2 ms 256 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 404 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 292 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 256 KB Output is correct
16 Correct 2 ms 256 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 380 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 9 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 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 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 18 ms 1528 KB Output is correct
4 Correct 18 ms 1528 KB Output is correct
5 Correct 9 ms 920 KB Output is correct
6 Correct 9 ms 1372 KB Output is correct
7 Correct 16 ms 2284 KB Output is correct
8 Correct 17 ms 2296 KB Output is correct
9 Correct 9 ms 1272 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 21 ms 2552 KB Output is correct
12 Correct 21 ms 2552 KB Output is correct
13 Correct 10 ms 1272 KB Output is correct
14 Correct 10 ms 1272 KB Output is correct
15 Correct 16 ms 2040 KB Output is correct
16 Correct 16 ms 2040 KB Output is correct
17 Correct 18 ms 2296 KB Output is correct
18 Correct 18 ms 2300 KB Output is correct
19 Correct 19 ms 2424 KB Output is correct
20 Correct 19 ms 2424 KB Output is correct