BZOJ 2720: [Violet 5]列队春游

2720: [Violet 5]列队春游

Time Limit: 5 Sec  Memory Limit: 128 MB
Submit: 189  Solved: 133
[Submit][Status][Discuss]

Description

 

Input

Output

Sample Input

 

Sample Output

 

HINT

 

 

Source

[Submit][Status][Discuss]

 

 

LTY大佬来嘲讽我了“你水不水,这题还要看题解的?”。

 

据说$O(N^{3})$的特别好想,优化一下就到了$O(N^{2})$,然后蒟蒻的我就抄了份$O(N)$的题解,然后和LH大爷推了好久。

 

 

 1 #include <cstdio>
 2 
 3 int n, cnt[1005], sum; double ans;
 4 
 5 signed main(void) {
 6     scanf("%d", &n); ++n;
 7     
 8     for (int i = 1, j; i < n; ++i)
 9         scanf("%d", &j), ++cnt[j];
10     
11     for (int i = 1; i <= 1000; ++i)
12         ans += 1.0 * cnt[i] * n / (n - sum), sum += cnt[i];
13     
14     printf("%.2lf\n", ans);
15 }

 

@Author: YouSiki

 

posted @ 2017-02-15 09:04  YouSiki  阅读(337)  评论(0编辑  收藏  举报