当前位置:网站首页>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
边栏推荐
- 平均风向风速计算(单位矢量法)
- P5.js death planet
- Oracle/PLSQL: Translate Function
- Press key to control LED status reversal
- [array] sword finger offer II 012 The sum of left and right subarrays is equal | sword finger offer II 013 Sum of two dimensional submatrix
- Window 加密壳实现
- 超級詳細,2 萬字詳解,吃透 ES!
- Regular expressions: Syntax
- pytorch 22 8种Dropout方法的简介 及 基于Dropout用4行代码快速实现DropBlock
- Flink学习1:简介
猜你喜欢

Parameter estimation -- Chapter 7 study report of probability theory and mathematical statistics (point estimation)

Why pass SPIF_ Sendchange flag systemparametersinfo will hang?

Super détaillé, 20 000 caractères détaillés, mangez à travers es!

Solve the problem of error reporting in cherry pick submission

企业数字化转型:信息化与数字化

Yuantou firm offer weekly record 20220627

Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message

Don't be brainwashed. This is the truth about the wages of 90% of Chinese people

H5 liquid animation JS special effect code

学习太极创客 — MQTT 第二章(一)QoS 服务质量等级
随机推荐
"All majors are persuading them to quit." is it actually the most friendly to college students?
Why pass SPIF_ Sendchange flag systemparametersinfo will hang?
学习太极创客 — MQTT(六)ESP8266 发布 MQTT 消息
Getting started with Scala_ Immutable list and variable list
Oracle/PLSQL: Translate Function
Topolvm: kubernetes local persistence scheme based on LVM, capacity aware, dynamically create PV, and easily use local disk
Paddlepaddle 20 implementation and use of exponentialmovingaverage (EMA) (support static graph and dynamic graph)
[Shangshui Shuo series] day 6
剑指Offer || :栈与队列(简单)
Lodash get JS code implementation
Flink Learning 2: Application Scenarios
STM32入门介绍
DAMA、DCMM等数据管理框架各个能力域的划分是否合理?有内在逻辑吗?
Test the respective roles of nohup and &
Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work
docker部署redis集群
Learn Tai Chi Maker - mqtt Chapter 2 (3) reserved messages
svg拖拽装扮Kitty猫
学习太极创客 — MQTT 第二章(二)ESP8266 QoS 应用
记录unity 自带读取excel的方法和遇到的一些坑的解决办法