#46361: cpp 超級簡單解


1121232@stu.wghs.tp.edu.tw (Ian911436)

學校 : 臺北市私立薇閣高級中學
編號 : 258883
來源 : [60.248.154.143]
最後登入時間 :
2025-06-20 09:40:35


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

int main(){
    vector<pair<int, int>> money; 
    int a, b;
    while(cin >> a >> b) {
        money.push_back({a, b});
    }
    sort(money.begin(), money.end(), greater<pair<int, int>>());
    
    long long total = 0;
    
    for(auto& m : money) {
        cout << m.first << "元鈔票共有" << m.second << "張" << endl;
        total += (long long)m.first * m.second;
    }
    
    cout << "總共有" << total << "元" << endl;
    
    return 0;
}