Submission #155837

#TimeUsernameProblemLanguageResultExecution timeMemory
155837m1sch3f쌀 창고 (IOI11_ricehub)C++17
100 / 100
21 ms2552 KiB


#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...