当前位置:网站首页>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
边栏推荐
- Flink learning 2: application scenarios
- Flink学习5:工作原理
- 455. distribute biscuits [distribution questions]
- svg拖拽装扮Kitty猫
- 2022茶艺师(高级)上岗证题库模拟考试平台操作
- 1. Project preparation and creation
- Canvas particles: mouse following JS effect
- Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
- paddlepaddle 21 基于dropout实现用4行代码dropblock
- Fork (), exec (), waitpid (), $? > > in Perl 8 combination
猜你喜欢

达梦数据库安装

Docker deploy redis cluster

流沙画模拟器源码

Quicksand painting simulator source code

Flink学习3:数据处理模式(流批处理)

dat. gui. JS star circle track animation JS special effect

svg拖拽装扮Kitty猫
![[micro service sentinel] degradation rules slow call proportion abnormal proportion abnormal constant](/img/4d/4d4424b609a3c0cd36c5c79daa8861.png)
[micro service sentinel] degradation rules slow call proportion abnormal proportion abnormal constant

Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages

lottie. JS creative switch button animal head
随机推荐
p5.js死亡星球
STM32入门介绍
Regular expressions: Syntax
Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages
超级详细,2 万字详解,吃透 ES!
Oracle/PLSQL: CharToRowid Function
Installing the Damon database using the command line
Yalm 100b: 100billion parameter open source large model from yandex, Russia, allowing commercial use
【数组】剑指 Offer II 012. 左右两边子数组的和相等 | 剑指 Offer II 013. 二维子矩阵的和
Flink学习4:flink技术栈
Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
Microsoft365 developer request
Flink learning 3: data processing mode (stream batch)
I earned 3W yuan a month from my sideline: the industry you despise really makes money!
"All majors are persuading them to quit." is it actually the most friendly to college students?
Calculation of average wind direction and speed (unit vector method)
清华&华为等 综述 | 语义通信:原则与挑战
Learn from Taiji Maker - mqtt Chapter 2 (I) QoS service quality level
Flink Learning 2: Application Scenarios
学习太极创客 — MQTT(九)ESP8266 同时订阅和发布 MQTT 消息