Submission #1042611

#TimeUsernameProblemLanguageResultExecution timeMemory
1042611AmirAli_H1비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1 ms348 KiB
// In the name of Allah

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

typedef		long long int			ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;
typedef		complex<ld>				cld;

#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		F						first
#define		S						second
#define		pb						push_back
#define		sep						' '
#define		endl					'\n'
#define		Mp						make_pair
#define		kill(x)					cout << x << '\n', exit(0)
#define		set_dec(x)				cout << fixed << setprecision(x);
#define		file_io(x,y)			freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 60 + 4;

int n; ll R;
ll A[maxn]; vector<ll> ls;
ll dp[maxn];

ll cal(int i, ll x) {
	if (x == 0) return 0;
	else if (x == 1) return 1;
	else if (x >= (1ll << i)) return dp[i - 1];
	int j = __lg(x);
	return dp[j - 1] + cal(j, min(x - (1ll << j), ls[j]));
}

ll count_tastiness(ll x, vector<ll> Ax) {
	n = len(Ax); R = x;
	for (int i = 0; i < n; i++) A[i] = Ax[i];
	
	ll sm = 0; ls.clear();
	for (int i = 0; i < n; i++) {
		sm += (A[i] << i);
		ll valx = (sm / x);
		ls.pb(max(0ll, valx - (1ll << i) + 1));
	}
	
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		dp[i] = cal(i, ls[i]);
		if (i == 0) dp[i]++;
		else dp[i] += dp[i - 1];
	}
	return dp[n - 1];
}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:51:5: warning: unused variable 'ans' [-Wunused-variable]
   51 |  ll ans = 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...
#Verdict Execution timeMemoryGrader output
Fetching results...