Advertisement
DidiMilikina

04. Energy Loss

Oct 30th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. //URL FOR THE TASK: https://judge.softuni.bg/Contests/Practice/Index/715#3
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int train_days;
  11.     int num_dancers;
  12.     cin >> train_days >> num_dancers;
  13.  
  14.     int energy_loss = 0;
  15.     int total_energy = 100 * num_dancers * train_days;
  16.  
  17.     for (int i = 1; i <= train_days; ++i)
  18.     {
  19.         int train_hours;
  20.         cin >> train_hours;
  21.  
  22.         int train = i % 2 == 0;
  23.         int hours = train_hours % 2 == 0;
  24.         int energy = 0;
  25.  
  26.         if (train && hours)
  27.         {
  28.             energy = 68;
  29.         }
  30.         else if (!train && hours)
  31.         {
  32.             energy = 49;
  33.         }
  34.         else if (train && !hours)
  35.         {
  36.             energy = 65;
  37.         }
  38.         else if (!train && !hours)
  39.         {
  40.             energy = 30;
  41.         }
  42.  
  43.         double current_energy_used = energy * num_dancers;
  44.         energy_loss += current_energy_used;
  45.     }
  46.  
  47.  
  48.     double left = total_energy - energy_loss;
  49.     double energy_each_person = left / num_dancers / train_days;
  50.  
  51.     if (energy_each_person > 50)
  52.     {
  53.         cout << "They feel good! Energy left: "
  54.             << fixed << setprecision(2) << energy_each_person
  55.             << endl;
  56.     }
  57.     else
  58.     {
  59.         cout << "They are wasted! Energy left: "
  60.             << fixed << setprecision(2) << energy_each_person
  61.             << endl;
  62.     }
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement