fork download
  1. #include <bits/stdc++.h>
  2. #include <map>
  3. using namespace std;
  4. int main ()
  5. {
  6. multimap<double,string> mymultimap;
  7. multimap<double,string>::iterator it;
  8. int n;
  9. double costoT=0.0, costo;
  10. string nombre;
  11. cin >> n;
  12. while(n>0){
  13. cin >> nombre >> costo;
  14. costoT+=costo;
  15. mymultimap.insert ( pair<double,string>(costo,nombre) );
  16. n--;
  17. }
  18. int i=1;
  19. for (it=mymultimap.end(), it--; it!=mymultimap.begin(); it--){
  20. cout << i << " | " << (*it).second << " | " << (*it).first << '\n';
  21. i++;
  22. }
  23. cout << i << " | " << (*it).second << " | " << (*it).first << '\n';
  24. cout << '\n' << costoT;
  25. return 0;
  26. }
Success #stdin #stdout 0s 5280KB
stdin
8
axion 23.60
fud 23.00
LaLa 23.01
Petalo 129.5
2Kg_manzanas 58.6
BimboG 30.5
MayonesaM 50.5
Colgate 23
stdout
1 | Petalo | 129.5
2 | 2Kg_manzanas | 58.6
3 | MayonesaM | 50.5
4 | BimboG | 30.5
5 | axion | 23.6
6 | LaLa | 23.01
7 | Colgate | 23
8 | fud | 23

361.71