Codeforces Round #346 (Div. 2) B (pair+vector的应用)
来源:互联网 发布:部落冲突 法师升级数据 编辑:程序博客网 时间:2024/06/03 20:07
http://codeforces.com/contest/659/problem/B
题意:每个区域中有一些人,这些人有人名和对应的分数,如果能够确定每个区域中分数前两名,就把这两个人的名字输出,如果不能确定,就输出问号。
vector相当于一个不知道下标要开多少大的数组,而且数组中可以存放更多类型的东西。
#include<bits/stdc++.h> //包含了所有的头文件#define MAXN 100005using namespace std; //不包括在头文件中int n, m, region, score;string name;vector<pair<int, string> >s[MAXN];bool cmp(pair<int,string> A,pair<int,string> B){ return A.first>B.first;}int main(){ scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { cin >> name >> region >> score; s[region].push_back(make_pair(score, name)); } for (int i = 1; i <= m; i++) { sort(s[i].begin(), s[i].end(), cmp); } for (int i = 1; i <= m; i++) { if (s[i].size() == 2) cout << s[i][0].second << ' ' << s[i][1].second << endl; else { if (s[i][1].first == s[i][2].first) cout << '?' << endl; else cout << s[i][0].second << ' ' << s[i][1].second << endl; } } return 0;}
0 0
- Codeforces Round #346 (Div. 2) B (pair+vector的应用)
- Codeforces Round #346 (Div. 2) B
- Codeforces Round #256 (Div. 2)(B)
- Codeforces Round #350 (Div. 2)(B)
- Codeforces Round #379 (Div. 2)B
- Codeforces Round #346 (Div. 2)-B. Qualifying Contest(排序)
- Codeforces Round #346 (Div. 2)(B)排序,模拟
- 栈应用--Codeforces Round #205 (Div. 2)B
- Codeforces Round #286 (Div. 2) B. Mr. Kitayuta's Colorful Graph +foyd算法的应用
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Codeforces Round #209 (Div. 2), problem: (D) Pair of Numbers
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- D. Pair of Numbers Codeforces Round #209 (Div. 2)
- Codeforces Round #209 (Div. 2) D - Pair of Numbers
- Codeforces Round #271 (Div. 2) F 线段树+pair
- Codeforces Round #377 (Div. 2) E. Sockets(map,pair,STL)
- Codeforces Round #209 (Div. 2) D.Pair of Numbers
- achartengine/MPAndroidChart——图表实现之Java
- 例程1. LKB -- 慕司板IAP15
- 1.Mysql数据库的优化技术(1)
- HDOJ 1202 The calculation of GPA
- linux yum命令详解
- Codeforces Round #346 (Div. 2) B (pair+vector的应用)
- Mac下使用git和github
- TextView设置字体颜色的几种方法简记
- Unity3D研究院之两种方式播放游戏视频-转自雨松mono
- java虚拟机HotSpot 的 GC 算法实现
- Apache 启动时报错 No installed service named "Apache2.4"
- Swift延迟加载简单介绍一二
- OpenStack : 使用 Fuel 部署私有云服务
- [Guava]——加入约束