日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

PAT甲级1062 Talent and Virtue:[C++题解]结构体、哈希表

發(fā)布時間:2025/4/5 c/c++ 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PAT甲级1062 Talent and Virtue:[C++题解]结构体、哈希表 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

    • 題目分析
    • 題目來源

題目分析



來源:acwing

分析:
分4個vector,單獨排序即可。

ac代碼

#include<bits/stdc++.h> using namespace std;const int N = 1e5 +10; int n ,l ,h; int d[N],x[N]; struct Person{string id;int de,cai;int total;bool operator<(const Person& t)const{if(total != t.total) return total > t.total;else if(de != t.de) return de > t.de;return id < t.id;}};vector<Person> persons[4]; unordered_map<string,Person> mp;int main(){cin >> n >> l >> h;int cnt = 0;for(int i =0 ;i<n; i++){char id[10];int a, b;scanf("%s%d%d",id,&a,&b);if( a <l || b<l) continue;else{cnt++;mp[id].id =id, mp[id].de = a, mp[id].cai = b, mp[id].total = a+b;if( a>=h && b>=h)persons[0].push_back(mp[id]);else if(a>=h) persons[1].push_back(mp[id]);else if( a >= b) persons[2].push_back(mp[id]);else persons[3].push_back(mp[id]);}}cout<<cnt<<endl;for(int i = 0; i<4;i++){auto s = persons[i];sort(s.begin(),s.end());for(auto person : s) printf("%s %d %d\n",person.id.c_str(), person.de,person.cai);}}

題目來源

PAT甲級1062 Talent and Virtue
https://www.acwing.com/problem/content/1550/

總結(jié)

以上是生活随笔為你收集整理的PAT甲级1062 Talent and Virtue:[C++题解]结构体、哈希表的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。