70632023-12-29 10:53:10MagyarKendeSZLGEgykorúak (75 pont)cpp17Wrong answer 60/754ms3824 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

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) {
    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 days_left(int e, int d) {
    return (e % 4 ? 365 : 366) - d;
}

int main() {
    speed;

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

    for (int i = 0; i < M; i++) {
        int FE, FH, FN, FD, FDL;
        cin >> FE >> FH >> FN;

        if (abs(E - FE) > 1) continue;
        
        if (E == FE) {
            result++;
            continue;
        }

        FD = days(FE, FH, FN), FDL = days_left(FE, FD);

        if (E < FE) {
            result += (DL + FD <= 365);
            continue;
        }

        if (FE < E) {
            result += (FDL + D <= 365);
            continue;
        }
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base60/75
1Accepted0/03ms1892 KiB
2Accepted0/04ms2084 KiB
3Accepted5/53ms2292 KiB
4Accepted5/53ms2396 KiB
5Accepted5/53ms2508 KiB
6Accepted5/53ms2732 KiB
7Accepted5/53ms2840 KiB
8Accepted5/53ms2816 KiB
9Accepted5/53ms2936 KiB
10Wrong answer0/53ms3024 KiB
11Accepted5/53ms3036 KiB
12Accepted5/53ms3116 KiB
13Wrong answer0/54ms3124 KiB
14Accepted5/54ms3252 KiB
15Accepted5/54ms3612 KiB
16Wrong answer0/54ms3708 KiB
17Accepted5/54ms3824 KiB