Submission #16060

# Submission time Handle Problem Language Result Execution time Memory
16060 2015-08-14T04:44:56 Z kaTkaHr 배낭 문제 준비하기 (GA9_invknapsack) C++
0 / 100
1000 ms 1932 KB
#include<stdio.h>
#include<vector>

using namespace std;

typedef long long ll;

ll D[305][305];
int K = 300;

vector<int> L;

void add(int x)
{
	int s = L.size(), e = s + 1;
	for (int i = 0; i <= K; i++) D[e][i] = D[s][i];
	for (int i = x; i <= K; i++) D[e][i] += D[s][i-x];
	L.push_back(x);
}

int main()
{
	for(ll R = 1e18 - 1e7; R <= 1e18 - 1e6; R++){
		D[0][0] = 1;
		for(int i = 1; i <= K; i *= 2){
			add(i);
		}
		while(D[L.size()][K] + D[L.size()][K-1] <= R) add(1);
		while(D[L.size()][K] != R){
			for(int j = 1; j <= K; j++){
				if(D[L.size()][K] + D[L.size()][K-j] <= R ){
					add(j);
					break;
				}
			}
		}
		if(L.size() >= 301 ) return !printf("%lld\n", R);
		else if( L.size() >= 200) printf("%d\n", L.size());
		L.clear();
	}
	printf("OK");
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 1932 KB Program timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -