hdu4505 小Q系列故事——电梯里的爱情

模拟,下楼梯不用停。

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <cmath>
 4 #include <string.h>
 5 using namespace std;
 6 int step[100+10];
 7 int main()
 8 {
 9     int c;
10     int n,i,j,cnt,maxstep;
11     int temp;
12     while(~scanf("%d",&c))
13     {
14         while(c--)
15         {
16             scanf("%d",&n);
17             cnt=0;
18             maxstep=0;
19             for(i=0;i<105;++i)
20                 step[i]=0;
21             for(i=0;i<n;++i)
22             {
23                 scanf("%d",&temp);
24                 step[temp]++;
25                 if(temp>maxstep)
26                 {
27                     maxstep=temp;
28                 }
29             }
30             for(i=1;i<=maxstep;++i)
31             {
32                 cnt+=6;
33                 if(step[i])
34                     cnt+=5;
35                 cnt+=step[i];
36             }
37             cnt+=maxstep*4;
38             printf("%d\n",cnt);
39         }
40     }
41     return 0;
42 }
原文地址:https://www.cnblogs.com/symons1992/p/2976216.html