fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. unsigned int n, ai, S=0, Ss=0, Sb=0;
  8. float Ck, c;
  9. string ti;
  10. cin >> n >> c;
  11. for(int i=1; i<=n; i++){
  12. cin >> ai >> ti;
  13. S += ai;
  14. if (ti == "bedroom"){
  15. Ss += ai;
  16. }
  17. else if (ti == "balcony"){
  18. Sb += ai;
  19. }
  20. }
  21. Ck = (S - Sb/2.) * c;
  22. cout << S << "\n"
  23. << Ss << "\n"
  24. << fixed << setprecision(6) << Ck << "\n";
  25. return 0;
  26. }
Success #stdin #stdout 0s 15240KB
stdin
6 75000
8 other
3 bathroom
2 bathroom
10 kitchen
16 bedroom
7 balcony
stdout
46
16
3187500.000000