标签:就是 cstring mission max iss lease input oid repr
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7051 Accepted Submission(s): 3587
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 const int maxn=2006; 6 int one[maxn],two[maxn]; 7 int dp[maxn]; 8 int out[4]; 9 10 int my_min(int a,int b) 11 { 12 return a<b?a:b; 13 } 14 15 void output(int ti) 16 { 17 if(ti==0){ 18 if(out[3]>=12) cout << " pm" << endl; 19 else cout << " am"<<endl; 20 return ; 21 } 22 if(ti==3){ 23 if(out[ti]<10) cout << "0" << out[ti]; 24 else cout << out[ti]; 25 } 26 else{ 27 if(out[ti]<10) cout << ":0"<< out[ti]; 28 else cout<< ":" << out[ti]; 29 } 30 output(ti-1); 31 } 32 33 int main() 34 { 35 ios_base::sync_with_stdio(0); cin.tie(0); 36 int T; 37 cin >> T; 38 while(T--){ 39 int k; 40 memset( dp, 0, sizeof dp); 41 cin >> k; 42 for(int i=1;i<=k;i++) 43 cin >> one[i]; 44 for(int i=2;i<=k;i++) 45 cin >> two[i]; 46 dp[1]=one[1]; 47 for(int i=2;i<=k;i++){ 48 dp[i]=my_min( dp[i-1]+one[i], dp[i-2]+two[i]); 49 } 50 51 out[1]=dp[k]; 52 out[3]=8; 53 out[2]=out[1]/60; 54 out[1]=out[1]%60; 55 out[3]=out[3]+out[2]/60; 56 out[2]=out[2]%60; 57 output(3); 58 } 59 return 0; 60 }
我的超水输出。
看看大神的输出。
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 const int maxn=2006; 6 int one[maxn],two[maxn],dp[maxn]; 7 8 int my_min(int a,int b) 9 { 10 return a<b?a:b; 11 } 12 13 int main() 14 { 15 int T; 16 cin >> T; 17 while(T--){ 18 int k; 19 memset( dp, 0, sizeof dp); 20 cin >> k; 21 for(int i=1;i<=k;i++) 22 cin >> one[i]; 23 for(int i=2;i<=k;i++) 24 cin >> two[i]; 25 dp[1]=one[1]; 26 for(int i=2;i<=k;i++){ 27 dp[i]=my_min( dp[i-1]+one[i], dp[i-2]+two[i]); 28 } 29 int temp,ss,hh,mm; 30 temp=dp[k]; 31 char s[5]; 32 ss=temp%60; 33 mm=(temp-ss)/60%60; 34 hh=(temp-ss-mm*60)/3600+8; 35 if(hh>=12) 36 strcpy( s, "pm"); 37 else strcpy( s, "am"); 38 printf("%02d:%02d:%02d %s\n",hh,mm,ss,s); 39 } 40 return 0; 41 }
标签:就是 cstring mission max iss lease input oid repr
原文地址:https://www.cnblogs.com/ZQUACM-875180305/p/9089748.html