Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (cin >> t && t != 0)
- {
- while (t--)
- {
- cin >> dd >> mm >> yy >> cons;
- vec.pb({{dd, mm, yy}, cons});
- }
- dd = vec[0].first.day, mm = vec[0].first.month, yy = vec[0].first.year;
- for (int i = 1; i < vec.size(); i++)
- {
- if (dd == vec[i].first.day - 1 && mm == vec[i].first.month && yy == vec[i].first.year)
- {
- cnt++;
- sum += (vec[i].second - vec[i - 1].second);
- }
- 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)))))
- {
- cnt++;
- sum += (vec[i].second - vec[i - 1].second);
- }
- else if (dd == 31 && mm == 12 && vec[i].first.day == 1 && vec[i].first.month == 1 && yy == vec[i].first.year - 1)
- {
- cnt++;
- sum += (vec[i].second - vec[i - 1].second);
- }
- dd = vec[i].first.day, mm = vec[i].first.month, yy = vec[i].first.year;
- }
- cout << cnt << " " << sum << endl;
- cnt = 0, sum = 0;
- vec.clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement