Submission #409097

# Submission time Handle Problem Language Result Execution time Memory
409097 2021-05-20T08:00:42 Z priority_queue Packing Biscuits (IOI20_biscuits) C++14
0 / 100
57 ms 1220 KB
#include <bits/stdc++.h>

#define forint(i, N) for (long long i = 0; i < (N); i++)

using namespace std;

unordered_map<long long, long long> m;

long long count(long long x, vector<long long>& a, long long max_y) {

	if (m[max_y] != 0) {
		return m[max_y];
	}

	if (max_y == 0) {
		m[0] = 1;
		return 1;
	}

	if (max_y == 1) {
		if (a[0] >= x) {
			m[1] = 2;
			return 2; // 0 & 1;
		}
		else {
			m[1] = 1;
			return 1; // 0 only 
		}
	}

	long long k = a.size();
	vector<long long> sum(61, 0);

	sum[0] = a[0];
	for (long long i = 1; i < k; i++) {
		sum[i] = sum[i - 1] + a[i] * (1ll << i);
	}

	for (long long i = k; i < 61; i++) {
		sum[i] = sum[i-1];
	}

	long long i = 0;
	while ((1ll << i) < max_y) {
		i++;
	}

	long long aa = count(x, a, 1ll << (i-1));

	if (sum[i-1] /  (1ll << (i-1)) <  x ) { 		
		m[max_y] = aa;
		return m[max_y];
	}
	else {
		m[max_y] = aa + count(x, a, min(max_y - (1ll << (i-1)), sum[i-1]/x - (1ll << (i-1)))) - 1; // (1ll << (i-1)) double counted 
		return  m[max_y];
	}
 }


long long count_tastiness(long long x, vector<long long> a) {
	m.clear();
	return count(x, a, 1e18);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 420 KB Output is correct
2 Incorrect 57 ms 1220 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -