#46396: C++ set<pair<int, int>, greater<pair<int, int>>>


1121228@stu.wghs.tp.edu.tw (你知道我是誰嗎!!??)

學校 : 臺北市私立薇閣高級中學
編號 : 266561
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:45:57

#include <bits/stdc++.h>
using namespace std;

int main(){
    set<pair<long long int, long long int>, greater<pair<long long int, long long int>>> s;
    long long int a, b, sum=0;
    while(cin >> a >> b){
        s.insert(make_pair(a, b));
        sum+=a*b;
    }
    for(auto p : s){
        cout << p.first << "元鈔票共有" << p.second << "張" << endl;
    }
    cout << "總共有" << sum << "元";
    return 0;
}