Advertisement
Ta7a99

Untitled

Jul 20th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. while (cin >> t && t != 0)
  2.     {
  3.         while (t--)
  4.         {
  5.             cin >> dd >> mm >> yy >> cons;
  6.             vec.pb({{dd, mm, yy}, cons});
  7.         }
  8.         dd = vec[0].first.day, mm = vec[0].first.month, yy = vec[0].first.year;
  9.         for (int i = 1; i < vec.size(); i++)
  10.         {
  11.             if (dd == vec[i].first.day - 1 && mm == vec[i].first.month && yy == vec[i].first.year)
  12.             {
  13.                 cnt++;
  14.                 sum += (vec[i].second - vec[i - 1].second);
  15.             }
  16.             else if (vec[i].first.day == 1 && mm == vec[i].first.month - 1 && yy == vec[i].first.year && ((dd == 31 && (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10)) || (dd == 30 && (mm == 4 || mm == 6 || mm == 9 || mm == 11)) || (mm == 2 && ((dd == 28 && yy % 4 != 0) || (dd == 29 && yy % 4 == 0 && yy % 100 != 0)))))
  17.             {
  18.                 cnt++;
  19.                 sum += (vec[i].second - vec[i - 1].second);
  20.             }
  21.             else if (dd == 31 && mm == 12 && vec[i].first.day == 1 && vec[i].first.month == 1 && yy == vec[i].first.year - 1)
  22.             {
  23.                 cnt++;
  24.                 sum += (vec[i].second - vec[i - 1].second);
  25.             }
  26.             dd = vec[i].first.day, mm = vec[i].first.month, yy = vec[i].first.year;
  27.         }
  28.         cout << cnt << " " << sum << endl;
  29.         cnt = 0, sum = 0;
  30.         vec.clear();
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement