pat1012 The Best Rank
来源:互联网 发布:剑三脸型数据下载 编辑:程序博客网 时间:2024/05/16 13:04
#include<cstdio>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<string>#include<cstring>#include<cmath>#include<map>#include<stack>#define N 10005#define ll long longusing namespace std;vector<pair<int,int> >s[4];pair<int,int>ans[2005];char ch[5] = "ACME";map<int,int>mp;int main(){int n,m,i,j,a,b,c,d,id;while(scanf("%d%d",&n,&m)!=EOF){int cnt = 0;for(i = 1;i<=n;i++){scanf("%d%d%d%d",&id,&a,&b,&c);if(!mp[id])mp[id] = ++cnt;s[0].push_back(make_pair(int(double(a+b+c)/3.0+0.5),mp[id]));s[1].push_back(make_pair(a,mp[id]));s[2].push_back(make_pair(b,mp[id]));s[3].push_back(make_pair(c,mp[id]));}for(i = 0;i<4;i++){int rk = 1;sort(s[i].begin(),s[i].end());for(j = n-1;j>=0;j--){id = s[i][j].second;if(j == n-1||s[i][j].first<s[i][j+1].first)rk = n-j;if(!i)ans[id] = make_pair(rk,i);else if(rk<ans[id].first)ans[id] = make_pair(rk,i);}}for(i = 0;i<m;i++){scanf("%d",&id);if(mp.find(id) == mp.end())printf("N/A\n");else printf("%d %c\n",ans[mp[id]].first,ch[ans[mp[id]].second]);}} return 0;}
0 0
- PAT1012. The Best Rank
- PAT1012 The Best Rank
- pat1012 The Best Rank
- PAT1012. The Best Rank (25)
- PAT1012. The Best Rank (25)
- 1012. The Best Rank
- PAT_1012: The Best Rank
- 1012. The Best Rank
- 1012. The Best Rank
- 1012.The Best Rank
- 1012. The Best Rank
- 1012 the Best Rank
- 1012. The Best Rank
- 1012 The Best Rank
- The Best Rank
- PAT_1012.The Best Rank
- The Best Rank (25)
- 1012. The Best Rank
- ecshop 添加404页面
- Android中ListView的适配器中getView()被重复调用的原因及解决方案.
- Javascript中的this
- 关于Xcode不显示中文解决方案
- CentOS6.4+Oracle11.2.0.4安装(单实例ASM)
- pat1012 The Best Rank
- C++拾遗--多线程:主线程与子线程的同步
- 业务数据备份功能
- 寻路算法基础研究
- swift UI专项训练14 ImageView图像视图
- 莫利定理:UVa 11178 Morley's Theorem
- UVa 511 - Do You Know the Way to San Jose? [STL应用]
- [LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql)
- C++ private成员变量作用域的扩展