// // Yukicoder // No.1701 half price //二次元可変配列 //vector > mass; //vector > memo; //#include "stdafx.h" #include #include #include #include //list #include //tree #include //連想配列 #include //hash #include //hash #include #include #include #include using namespace std; typedef unsigned long long ULL; typedef signed long long SLL; typedef unsigned int UINT; #define START (0) #define RIGHT (1) #define UP (2) #define LEFT (3) #define DOWN (4) #define DATA_MAX (1000000) #define FMAX(a,b) ((a)>(b)?(a):(b)) #define FMIN(a,b) ((a)<(b)?(a):(b)) vector > memo2; vector memo1; vector c; vector v; vector dp; SLL H ,A, B, T; SLL N, W, comp; UINT hashtable=0; //n番目の品物を選んだら1< W) { //cout << "return W" << endl; //PrintHashTable(); return 0; } if (n >= N) { //cout << "return N" << endl; //PrintHashTable(); return 0; } //cout << "買わない場合:data=" << data[n] << ", n=" << n << ", ans=" << ans << endl; hashtable= hashtable & ~( 1 << (n + 1)); func(data, n + 1, ans); //cout << "半額にして買う場合:data=" << data[n] << ", n=" << n << ", ans=" << ans << endl; hashtable = hashtable | (1 << (n + 1)); func(data, n + 1, ans + data[n] / 2); //cout << "買う場合:data=" << data[n] << ", n=" << n << ", ans=" << ans << endl; hashtable = hashtable | (1 << (n + 1)); func(data, n + 1, ans + data[n] ); //1つ上の階層に戻るときはフラグをクリアしておく hashtable = hashtable & ~(1 << (n + 1)); return 0; } int main(int argc, char *argv[]) { //char s[] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' }; //char ans[30]; //float min = INFINITY; //SLL dp[5][35]; //DP 少し余裕をもって配列を確保 SLL a[15]; v.resize(17000); //ベクタ配列の初期化(2^14以上) cin >> N; cin >> W; for (int i=0;i> a[i]; } func(&a[0], 0, 0); cout << comp << endl; /////////////////// //cout << endl; //getchar(); return 0; //end }