symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理

模拟,下楼梯不用停。

 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 }

 

posted on 2013-03-22 19:07  symons  阅读(284)  评论(0编辑  收藏  举报