Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <set>
- #include <vector>
- class Exam {
- public:
- int t, y, m, d;
- };
- bool compare(Exam& f, Exam& s) {
- return (f.y < s.y)
- || (f.y == s.y && f.m < s.m)
- || (f.y == s.y && f.m == s.m && f.d < s.d)
- || (f.y == s.y && f.m == s.m && f.d == s.d && f.t > s.t);
- }
- int dist(Exam& f, Exam& s) {
- int d_d = 0;
- for (int i = f.y; i != s.y; ++i) {
- if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
- d_d += 366;
- } else {
- d_d += 365;
- }
- }
- std::set<int> more_days({1, 3, 5, 7, 8, 10, 12});
- for (int i = f.m; i != s.m; ++i) {
- if (more_days.find(i) != more_days.end()) {
- d_d += 31;
- } else {
- d_d += 30;
- }
- }
- d_d += s.d - f.d;
- return d_d;
- }
- int main() {
- int n, t;
- std::cin >> n;
- std::string name, date;
- std::vector<Exam> ex(n);
- for (int i = 0; i != n; ++i) {
- std::cin >> name >> date >> t;
- ex[i].t = t;
- ex[i].d = (date[0] - '0') * 10
- + date[1] - '0';
- ex[i].m = (date[3] - '0') * 10
- + date[4] - '0';
- ex[i].y = (date[6] - '0') * 1000
- + (date[7] - '0') * 100
- + (date[8] - '0') * 10
- + date[9] - '0';
- }
- std::sort(ex.begin(), ex.end(), &compare);
- for (int i = 1; i != ex.size(); ++i) {
- if ()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement