Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("tv.in");ofstream fout("tv.out");
- //ifstream fin("input");ofstream fout("output");
- int k, n, maxx = 0, ans1, ans2;
- int dur, h, m, s;
- int mars[100005];
- int hs = 3600 * 24;
- void afis(int nr) {
- h = nr / 3600; nr -= h * 3600;
- m = nr / 60; nr -= m * 60;
- s = nr;
- if (h < 10) {
- fout << 0;
- }
- fout << h << ":";
- if (m < 10) {
- fout << 0;
- }
- fout << m << ":";
- if (s < 10) {
- fout << 0;
- }
- fout << s;
- }
- int main() {
- fin >> k;
- fin >> n;
- for (int i = 1; i <= n; i++) {
- char c;
- fin >> dur >> h >> c >> m >> c >> s;
- mars[s + 60 * m + 3600 * h] += 1;
- mars[s + 60 * m + 3600 * h + dur] -= 1;
- }
- ans1 = hs;
- for (int i = 0; i < hs; i++) {
- mars[i] = mars[i - 1] + mars[i];
- if (mars[i] > maxx) {
- maxx = mars[i];
- ans2 = i;
- }
- if (mars[i]) {
- ans1--;
- }
- }
- if (k == 1) {
- afis(ans1);
- }
- else {
- afis(ans2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement