Advertisement
great_lexa

Untitled

May 29th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <set>
  4. #include <vector>
  5.  
  6. class Exam {
  7. public:
  8. int t, y, m, d;
  9. };
  10.  
  11. bool compare(Exam& f, Exam& s) {
  12. return (f.y < s.y)
  13. || (f.y == s.y && f.m < s.m)
  14. || (f.y == s.y && f.m == s.m && f.d < s.d)
  15. || (f.y == s.y && f.m == s.m && f.d == s.d && f.t > s.t);
  16. }
  17.  
  18. int dist(Exam& f, Exam& s) {
  19. int d_d = 0;
  20. for (int i = f.y; i != s.y; ++i) {
  21. if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
  22. d_d += 366;
  23. } else {
  24. d_d += 365;
  25. }
  26. }
  27. std::set<int> more_days({1, 3, 5, 7, 8, 10, 12});
  28. for (int i = f.m; i != s.m; ++i) {
  29. if (more_days.find(i) != more_days.end()) {
  30. d_d += 31;
  31. } else {
  32. d_d += 30;
  33. }
  34. }
  35. d_d += s.d - f.d;
  36. return d_d;
  37. }
  38. int main() {
  39. int n, t;
  40. std::cin >> n;
  41. std::string name, date;
  42. std::vector<Exam> ex(n);
  43. for (int i = 0; i != n; ++i) {
  44. std::cin >> name >> date >> t;
  45. ex[i].t = t;
  46.  
  47. ex[i].d = (date[0] - '0') * 10
  48. + date[1] - '0';
  49.  
  50. ex[i].m = (date[3] - '0') * 10
  51. + date[4] - '0';
  52.  
  53. ex[i].y = (date[6] - '0') * 1000
  54. + (date[7] - '0') * 100
  55. + (date[8] - '0') * 10
  56. + date[9] - '0';
  57. }
  58. std::sort(ex.begin(), ex.end(), &compare);
  59. for (int i = 1; i != ex.size(); ++i) {
  60. if ()
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement