Advertisement
Guest User

Zadacha

a guest
Oct 23rd, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <vector>
  5. #include <map>
  6. #include <set>
  7. #include <queue>
  8. #include <algorithm>
  9. #include <string>
  10.  
  11. using namespace std;
  12.  
  13. struct od
  14. {
  15.     int l;
  16.     int h;
  17.     char f;
  18.     int m;
  19. } od[1400];
  20.  
  21.  
  22. int main()
  23. {
  24.     int v, d, n, count = 0, suml;
  25.     double time = 0;
  26.     bool check = false;
  27.  
  28.     cin >> v >> d >> n;
  29.  
  30.     cin >> od[0].l >> od[0].h >> od[0].f >> od[0].m;
  31.  
  32.     suml = od[0].l;
  33.  
  34.     for (int i = 1; i < n; i++)
  35.     {
  36.         cin >> od[i].l >> od[i].h >> od[i].f >> od[i].m;
  37.         od[i].l -= od[i-1].l;
  38.         suml += od[i].l;
  39.  
  40.     }
  41.  
  42.  
  43.     for (int i = 0; i < n; i++)
  44.         {
  45.             time += double(od[i].l) / v;
  46.  
  47.             if (time >= od[i].h*60 + od[i].m)
  48.             {
  49.                 time += d;
  50.                 count++;
  51.             }
  52.  
  53.             if (i == (n-1) && od[i].h*60 + od[i].m > time)
  54.                 check = true;
  55.         }
  56.  
  57.  
  58.     if (!check)
  59.         {
  60.             time += double(suml) / v;
  61.             time += (n - count) * d;
  62.         }
  63.     else
  64.         {
  65.             time = od[n-1].h * 60 + od[n-1].m;
  66.             time += n * d;
  67.             time += double(suml / v)*2;
  68.         }
  69.  
  70.  
  71.     int time2 = ceil(time);
  72.  
  73.  
  74.     if (time2 / 60 < 10)
  75.         if (time2 % 60 > 10)
  76.             cout << "0" << time2 / 60 << ":" << time2 % 60;
  77.         else
  78.             cout << "0" << time2 / 60 << ":" <<"0" << time2 % 60;
  79.     else
  80.         if (time2 % 60 > 10)
  81.             cout << time2 / 60 << ":" << time2 % 60;
  82.         else
  83.             cout << time2 / 60 << ":" << "0" << time2 % 60;
  84.  
  85.  
  86.     return 0;
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement