int main() {
		uint32_t testcases = g_fi.ReadNext();
/*				max2 = (float **)calloc(2000,  sizeof(float*));
				used = (int **)calloc(2000  ,  sizeof(int *));
				for (int r = 0; r < 2000;r++) {
					max2[r] = (float *)calloc(2000  ,  sizeof(float));
					used[r] = (int *)calloc(2000  ,  sizeof(int));
				}*/
//			memset(max2, 0, sizeof(float)*2000*2000);
			memset(used, 0, sizeof(int)*2000);

		for (tc = 0; tc < testcases; ++tc) {
				 //cout<<"Test Cases  "<<i<<endl;
				 NumberofDiamonds =  g_fi.ReadNext();
				diamonds = (int *)malloc(NumberofDiamonds*sizeof(int *));
				for (int r = 0; r < NumberofDiamonds;r++) {
						uint32_t S = g_fi.ReadNext();
						diamonds[r] = S;
					}
				
		
				//This variable will be used to maintain the index of the  lookup table which will help in DP
				int index = 1;

				//Building the lookup table for the dynamic program max2 thing.

				float answertc;
				steps = 0;
				int lev = ceil(log(NumberofDiamonds)/log(2));
				//Sorting the Elements.
				//Iteration over the activity store available with us .
					answertc = expecteddiamondvalue(0,NumberofDiamonds-1,lev);	
				/*for ( int i = 0;i < activitystore.size()+1;i++) {
					cout<<"Max t"<<i<<"   "<<max2[i];
				}*/
				cout<<"Steps :" <<steps;
				printf("%f\n",answertc);

//				memset(max2, 0, sizeof(float)*2000*2000);
				for(int i=0;i<NumberofDiamonds;i++) {
					cout<<"   i"<<used[i]<<endl;
				}
				memset(used, 0, sizeof(int)*2000);
				free(diamonds);
}

		//				g_fo.PrintUint(answertc, '\n');
				////cout<<"final answer  : "<<a<<"After division by :"<<divis<<endl;
/*
				for (int r = 0; r < NumberofDiamonds;r++) {
					free(max2[r]);
					free(used[r]);
				}
				free(max2);
				free(used);*/
		g_fo.Flush();
		return 0;
}
예제 #2
0
int main() {
		// Taking input of number of testcases to be solved.
		uint32_t testcases =  g_fi.ReadNext();


		//Loop to go through process number of testcases time.
		for (uint32_t i = 0; i < testcases; ++i) {
			
				// This map will hold the level wise total score of soint.
				map<int,int> sointlevelscore;
				// This map will hold the level wise total score of sofloat.
				map<int,int> sofloatlevelscore;


				// Inputing number of Warriers in each team Soint and soFloat
				uint32_t sointN = g_fi.ReadNext();
				uint32_t sofloatM = g_fi.ReadNext();
				
				for ( uint32_t j  = 0;j < sointN ; j++ ) {
					uint32_t chakra = g_fi.ReadNext();
					uint32_t level = g_fi.ReadNext();
					if (sointlevelscore.find(level) == sointlevelscore.end()) {
						sointlevelscore[level] = chakra;
					} else {
						sointlevelscore[level] = sointlevelscore.find(level)->second + chakra;
					}
				}

				for ( uint32_t j  = 0;j < sofloatM ; j++ ) {
					uint32_t chakra = g_fi.ReadNext();
					uint32_t level = g_fi.ReadNext();
					if (sofloatlevelscore.find(level) == sofloatlevelscore.end()) {
						sofloatlevelscore[level] = chakra;
					} else {
						sofloatlevelscore[level] = sofloatlevelscore.find(level)->second + chakra;
					}
				}
				int minimumchakra = 0;
	//To check how much time actual logic takes
/*
				map<int,int>::iterator chakrainterator;
				for ( chakrainterator = sointlevelscore.begin();chakrainterator != sointlevelscore.end();chakrainterator++) {
					int score = ( sofloatlevelscore[(*chakrainterator).first] - (*chakrainterator).second ); 
					if ( score > 0 ) {
						minimumchakra += score; 						
					}
				}
*/

				g_fo.PrintUint(minimumchakra, '\n');
		}
		g_fo.Flush();
		return 0;
}