70632023-12-29 10:53:10MagyarKendeSZLGEgykorúak (75 pont)cpp17Hibás válasz 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base60/75
1Elfogadva0/03ms1892 KiB
2Elfogadva0/04ms2084 KiB
3Elfogadva5/53ms2292 KiB
4Elfogadva5/53ms2396 KiB
5Elfogadva5/53ms2508 KiB
6Elfogadva5/53ms2732 KiB
7Elfogadva5/53ms2840 KiB
8Elfogadva5/53ms2816 KiB
9Elfogadva5/53ms2936 KiB
10Hibás válasz0/53ms3024 KiB
11Elfogadva5/53ms3036 KiB
12Elfogadva5/53ms3116 KiB
13Hibás válasz0/54ms3124 KiB
14Elfogadva5/54ms3252 KiB
15Elfogadva5/54ms3612 KiB
16Hibás válasz0/54ms3708 KiB
17Elfogadva5/54ms3824 KiB