Simulates the clock's second hand movement, gives the time to find the angle. Note that each set of outputs has a space
After you want to write code, so a water problem for 50 minutes, too weak ...
1#include <cstdio>2#include <string>3#include <cstring>4#include <algorithm>5#include <iostream>6 using namespacestd;7 8 strings;9 intdp[200010][2];Ten intsave[200010]; One A intMain () { - intT; - intCAS =0; thescanf"%d", &T); - while(t--){ -CIN >>s; -Memset (DP,0,sizeof(DP)); +memset (Save,0,sizeof(save)); - for(inti =0; I < s.length (); i++){ +scanf"%d", &save[i]); A } at if(s[0] =='1'){ -dp[0][1] + = save[0]; -dp[0][0] =0; -}Else if(s[0] =='0'){ -dp[0][0] = dp[1][1] =0; -}Else{ indp[0][1] + = save[0]; -dp[0][0] =0; to } + //printf ("%d\n", Max (Dp[0][1], dp[0][0])); - for(inti =1; I < s.length (); i++){ the if(S[i] = ='1'){ * if(s[i-1] =='0'){ $dp[i][1] = dp[i-1][0] +Save[i];Panax Notoginseng}Else if(s[i-1] =='1'){ -dp[i][1] = dp[i-1][1]; the}Else if(s[i-1] =='?'){ +dp[i][1] = max (dp[i-1][0] + save[i], dp[i-1][1]); A } the}Else if(S[i] = ='0'){ + if(s[i-1] =='0'){ -dp[i][0] = dp[i-1][0]; $}Else if(s[i-1] =='1'){ $dp[i][0] = dp[i-1][1] +Save[i]; -}Else if(s[i-1] =='?'){ -dp[i][0] = max (dp[i-1][1] + save[i], dp[i-1][0]); the //printf ("dp[%d][0] =%d \ n", dp[i][0]); - }Wuyi}Else if(S[i] = ='?'){ the if(s[i-1] =='0'){ -dp[i][1] = dp[i-1][0] +Save[i]; Wu //printf ("dp[%d][1] =%d \ n", I, dp[i][1]); -dp[i][0] = dp[i-1][0]; About //printf ("dp[%d][0] =%d \ n", I, dp[i][0]); $}Else if(s[i-1] =='1'){ -dp[i][0] = dp[i-1][1] +Save[i]; -dp[i][1] = dp[i-1][1]; -}Else if(s[i-1] =='?'){ Adp[i][0] = max (dp[i-1][1] + save[i], dp[i-1][0]); +dp[i][1] = max (dp[i-1][0] + save[i], dp[i-1][1]); the } - } $ //printf ("%d\n", Max (Dp[i][1], dp[i][0])); the } the intn = s.length ()-1; theprintf"Case #%d:%d\n", ++cas, Max (dp[n][1], dp[n][0])); the } - return 0; in}
hdu5387-Simulated water problem