【CodeForces】[651B]Beautiful Paintings
2016-05-30 00:00
288 查看
刚开始以为是简单的排序
后来发现是重新排列后
只要有
a[i+1]>a[i]变使cnt++
所以最优排列方法可以是
类似于12312312323333这种
#include<stdio.h> #include<string.h> int a[1020]; int main() { int n; while(scanf("%d",&n)!=EOF) { int cnt=0; memset(a,0,sizeof(a)); for(int i=0; i<n; i++) { int t; scanf("%d",&t); a[t]++; } int res=0; while(n) { for(int i=1; i<1020; i++) { if(a[i]) { res++; n--; a[i]--; } } res--; } printf("%d\n",res); } return 0; }
题目地址:【CodeForces】[651B]Beautiful Paintings
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B