1012. The Best Rank (25)
来源:互联网 发布:网络手机兼职是真的吗 编辑:程序博客网 时间:2024/05/18 02:27
#include <iostream>#include <algorithm>#include <vector>#include <map>#include <string>using namespace std;struct score {int s[4];};char ci[] = "CMEA";int main(int argc, char **argv) {int n, m;map<string, score> ss;vector<int> crs[4];cin >> n >> m;for(int i = 0; i < 4; i ++) {crs[i].reserve(n);}for(int i = 0; i < n; i ++) {string id;cin >> id;score s = {0};for(int j = 0; j < 3; j ++) {int tmp;cin >> tmp;s.s[j] = tmp;s.s[3] += tmp;}s.s[3] /= 3;for(int j = 0; j < 4; j ++) {crs[j].push_back(s.s[j]);}ss[id] = s;}for(int i = 0; i < 4; i ++) {sort(crs[i].begin(), crs[i].end());}for(int i = 0; i < m; i ++) {string id;cin >> id;map<string, score>::iterator ssit;ssit = ss.find(id);if(ssit != ss.end()) {int * s = ssit->second.s;int rank[4], index=0;for(int j = 0; j < 4; j ++) {rank[j] = crs[j].end() - upper_bound(crs[j].begin(), crs[j].end(), s[j]);if(rank[j] < rank[index])index = j;}if(rank[3] <= rank[index])index = 3;cout << rank[index] + 1 << ' ' << ci[index] << endl;}elsecout << "N/A" << endl;}return 0;}
0 0
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 1012. The Best Rank (25)
- 产品经理之驱动开发
- 在go环境中架设protobuf
- OC方法详解
- 64位的ubuntu14.10系统下安装python2.7.9
- jdk集合源码之LinkedList
- 1012. The Best Rank (25)
- android listview 设置点击item背景颜色效果
- 树莓派架设http服务器挂载网页
- select、poll、epoll的比较
- day07_java面向对象+构造函数+this+static关键字
- linux suid,sgid,bit stick(粘贴位),acl权限的记录
- jQuery性能优化
- NoSQL
- 匆匆那年 高清下载