70682023-12-29 11:04:33MagyarKendeSZLGEgykorúak (75 pont)cpp17Accepted 75/7517ms3440 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)

using namespace std;

const int N_lengthS[13] = {
    0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

const int S_lengthS[13] = {
    0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

int days(int e, int h, int n) {
    for (int i = 1; i < e; i++) {
        n += (i % 4 ? 365 : 366);
    }
    if (e % 4) {
        for (int i = 1; i < h; i++) {
            n += N_lengthS[i];
        }
    } else {
        for (int i = 1; i < h; i++) {
            n += S_lengthS[i];
        }
    }
    return n;
}

int main() {
    speed;

    int M, E, H, N, D, result = 0;
    cin >> M >> E >> H >> N;
    
    D = days(E, H, N);

    while (M--) {
        int FE, FH, FN;
        cin >> FE >> FH >> FN;

        if (FE == E) {
            result++;
            continue;
        }

        if (abs(FE - E) == 1) {
            result += (abs(days(FE, FH, FN) - D) <= 365);
        }

    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1892 KiB
2Accepted0/017ms2084 KiB
3Accepted5/53ms2296 KiB
4Accepted5/53ms2524 KiB
5Accepted5/53ms2668 KiB
6Accepted5/53ms2764 KiB
7Accepted5/53ms2732 KiB
8Accepted5/53ms3012 KiB
9Accepted5/53ms2880 KiB
10Accepted5/54ms3076 KiB
11Accepted5/56ms3216 KiB
12Accepted5/57ms3300 KiB
13Accepted5/58ms3296 KiB
14Accepted5/59ms3336 KiB
15Accepted5/510ms3340 KiB
16Accepted5/513ms3340 KiB
17Accepted5/514ms3440 KiB