Submission #828836

# Submission time Handle Problem Language Result Execution time Memory
828836 2023-08-17T17:09:46 Z Abrar_Al_Samit Packing Biscuits (IOI20_biscuits) C++17
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
#include "biscuits.h"

using namespace std;

int k = 122;
vector<long long>a;

long long x;
map<long long, long long>dp[125];

long long solve(int i, long long j) {
	if(i>=k) return 1;

	if(dp[i].count(j)) return dp[i][j];
	long long &ret = dp[i][j];
	if(ret!=-1) return ret;

	ret = 0;
	long long cr = a[i] + j;

	ret = solve(i+1, cr/2);
	if(cr>=x) ret += solve(i+1, (cr-x)/2);
	return ret;
}
long long count_tastiness(long long X, vector<long long> A) {
	A.resize(122);
	a = A, x = X;

	for(int i=0; i<k-1; ++i) {
		if(a[i]<=x) continue;
		long long take = max(0LL, a[i] - x);
		a[i] -= take - (take & 1);
		a[i+1] += take / 2;
	}

	memset(dp, -1, sizeof dp);
	return solve(0, 0);
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:37:26: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'class std::map<long long int, long long int>' with no trivial copy-assignment [-Wclass-memaccess]
   37 |  memset(dp, -1, sizeof dp);
      |                          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from biscuits.cpp:1:
/usr/include/c++/10/bits/stl_map.h:100:11: note: 'class std::map<long long int, long long int>' declared here
  100 |     class map
      |           ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -