fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. int N;
  7. cin >> N;
  8.  
  9. long long total = 0;
  10. string terlaris = "";
  11. long long maxJumlah = -1;
  12.  
  13. for(int i = 0; i < N; i++) {
  14. string kode;
  15. long long harga, jumlah;
  16. cin >> kode >> harga >> jumlah;
  17.  
  18. total += harga * jumlah;
  19.  
  20. if(jumlah > maxJumlah ||
  21. (jumlah == maxJumlah && kode < terlaris)) {
  22. maxJumlah = jumlah;
  23. terlaris = kode;
  24. }
  25. }
  26.  
  27. cout << total << endl;
  28. cout << terlaris << endl;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
A 1000 2
B 1500 1
C 2000 3
stdout
9500
C