当前位置:网站首页>PAT甲级 1025 PAT Ranking
PAT甲级 1025 PAT Ranking
2022-06-27 02:44:00 【九是否非随机的称呼】
注意ranking是累加
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
struct testee{
string ID;
int score;
int loc;
int wholerank;
int locrank;
};
bool compareloc(const testee &a, const testee &b){
if(a.score > b.score) return true;
else if(a.score < b.score) return false;
else if(a.score == b.score){
if(a.ID <= b.ID) return true;
else return false;
}
}
int main(void){
string s, s0, sk;
int m, n, k, i, j, f, h;
cin>>n;
vector<testee> v, vx;
testee tst;
vector<int> vtr;
for(i = 0; i < n; i++){
cin>>m;
vtr.push_back(m);
for(j = 0; j < m; j++){
cin>>tst.ID>>tst.score;
tst.loc = i + 1;
vx.push_back(tst);
}
}
h = 0;
for(i = 0; i < n; i++){
vector<testee> v0;
k = 1;
for(j = 0; j < vtr[i]; j++){
tst = vx[h++];
v0.push_back(tst);
}
sort(v0.begin(), v0.end(), compareloc);
if(v0.size()>0) v0[0].locrank = k;
for(j = 1; j < vtr[i]; j++){
k++;
if(v0[j - 1].score==v0[j].score) v0[j].locrank = v0[j - 1].locrank;
else v0[j].locrank = k;
}
for(j = 0; j < vtr[i]; j++) v.push_back(v0[j]);
}
k = 1;
sort(v.begin(), v.end(), compareloc);
if(v.size()>0) v[0].wholerank = k;
for(j = 1; j < v.size(); j++){
k++;
if(v[j - 1].score==v[j].score) v[j].wholerank = v[j - 1].wholerank;
else v[j].wholerank = k;
}
cout<<v.size()<<endl;
for(j = 0; j < v.size(); j++) cout<<v[j].ID<<" "<<v[j].wholerank<<" "<<v[j].loc<<" "<<v[j].locrank<<endl;
return 0;
} https://github.com/ZouJiu1/PAT
https://github.com/ZouJiu1/PAT
边栏推荐
- TP5 Spreadsheet Excle 表格导出
- Yalm 100b: 100billion parameter open source large model from yandex, Russia, allowing commercial use
- Oracle/PLSQL: NumToDSInterval Function
- [Shangshui Shuo series] day 6
- TechSmith Camtasia latest 2022 detailed function explanation Download
- lottie.js创意开关按钮动物头像
- Questions and answers of chlor alkali electrolysis process in 2022
- Flink learning 5: how it works
- Yiwen teaches you Kali information collection
- How to solve the problem of low applet utilization
猜你喜欢

Flink learning 5: how it works

Flink学习2:应用场景

Installing the Damon database using the command line

What if asreml-r does not converge in operation?

1. Project preparation and creation

Flink learning 2: application scenarios

Flink学习5:工作原理

C language -- Design of employee information management system

Flink学习1:简介

dat. gui. JS star circle track animation JS special effect
随机推荐
解决cherry pick提交报错问题
Oracle/PLSQL: Ltrim Function
SQLite reader plug-in tests SQLite syntax
Leetcode 785: judgment bipartite graph
Parameter estimation -- Chapter 7 study report of probability theory and mathematical statistics (point estimation)
Oracle/PLSQL: Soundex Function
【数组】剑指 Offer II 012. 左右两边子数组的和相等 | 剑指 Offer II 013. 二维子矩阵的和
栈溢出漏洞
Oracle/PLSQL: CharToRowid Function
Flink学习5:工作原理
我是怎样简化开源系统中的接口的开发的?
Oracle/PLSQL: To_ Clob Function
Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages
Svg drag dress Kitty Cat
Oracle/PLSQL: From_ Tz function
LeetCode 785:判断二分图
2022中式面点师(高级)复训题库及在线模拟考试
dat. gui. JS star circle track animation JS special effect
【一起上水硕系列】Day 6
Don't be brainwashed. This is the truth about the wages of 90% of Chinese people