Codeforces Round #223 (Div. 2) 解题报告
2014-01-13 02:05
387 查看
这次只做出来两道水题,真是太糟糕了。先挖个坑,到时候再来填吧。
Problem A Sereja and Dima
思路:每次都会从两边去找一个最大的。
代码如下:
View Code
Problem A Sereja and Dima
思路:每次都会从两边去找一个最大的。
代码如下:
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #include <queue> #include <stack> #include <vector> #define MP(a, b) make_pair(a, b) #define PB(a) push_back(a) using namespace std; typedef long long ll; typedef pair<int ,int> pii; typedef pair<unsigned int, unsigned int> puu; typedef pair<int ,double> pid; typedef pair<ll, int> pli; const int INF = 0x3f3f3f3f; const double eps = 1e-6; const int LEN = 100010; int hash[LEN]; int main() { // freopen("in.txt", "r", stdin); int n; while(scanf("%d", &n)!=EOF){ memset(hash, 0, sizeof hash); int ans = 0; for(int i=0; i<n; i++){ int temp; scanf("%d", &temp); hash[temp]++; if(hash[temp]<3)ans++; } int maxt; for(int i=5000; i>=0; i--){ if(hash[i]){ maxt = i; break; } } if(hash[maxt]>=2)ans--; printf("%d\n", ans); int f = 1; for(int i=0; i<=5000; i++){ if(hash[i]){ if(f==1){printf("%d", i);f=0;} else printf(" %d", i); } } for(int i=5000; i>=0; i--){ if(hash[i]>=2){ if(i==maxt)continue; if(f==1){printf("%d", i);f=0;} else printf(" %d", i); } } printf("\n"); } return 0; }
View Code
相关文章推荐
- Codeforces Round #217 (Div. 2) 解题报告
- 解题报告:Codeforces Round #421 (Div. 2) A-E
- [Updating]Codeforces Round #402 (Div. 1)解题报告
- Codeforces Round #377 (Div. 2) 解题报告
- Codeforces Round #221 (Div. 2) B. I.O.U. C. Divisible by Seven D. Maximum Submatrix 2 解题报告
- Codeforces 451(#258 (Div. 2) ) 解题报告
- 【解题报告】Codeforces Round #379 (Div. 2)
- Topcoder SRM 583 DIV2 解题报告
- Codeforces Round #284 (Div. 2) C. Crazy Town ACM解题报告(几何)
- Codeforces Round #284 (Div. 2) C题(计算几何)解题报告
- Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes ACM解题报告(预处理)
- Codeforces Round #231 (Div. 2) 解题报告
- Codeforces Round #192 (Div. 2) 解题报告 //缺E
- codeforces#254DIV2解题报告
- Codeforces 467(#267 (Div. 2) ) 解题报告
- codeforces Round #238(div2) B解题报告
- 【解题报告】Codeforces Round #349 (Div. 2)
- codeforces Round #271(div2) B解题报告
- codeforces Round #241(div2) A解题报告
- Codeforces Round#320 Div2 解题报告