165422025-05-06 17:09:33SaroltaMihalyEgykorúak (75 pont)cpp17Accepted 75/758ms548 KiB
#include <iostream>
#include <vector>

using namespace std;

bool szokoEve(int ev) 
{
    if (ev % 4 == 0) 
    {
        if (ev % 100 == 0) 
        {
            return ev % 400 == 0;
        }
        return true;
    }
    return false;
}

int datumhozNapok(int ev, int honap, int nap) 
{
    int napok = 0;

    for (int i = 1950; i < ev; i++) 
    {
        napok += szokoEve(i) ? 366 : 365;
    }

    int segedfeb = 0;
    if (szokoEve(ev))
    {
        segedfeb = 29;
    }
    else
    {
        segedfeb = 28;
    }

    int honapokNapjai[] = { 31, segedfeb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    for (int i = 0; i < honap - 1; i++) 
    {
        napok += honapokNapjai[i];
    }

    napok += nap;

    return napok;
}

bool ellenoriz(int ev, int h, int n)
{
    if (ev < 1950 || ev>2050)
    {
        return false;
    }
    if (h < 1 || h>12)
    {
        return false;
    }
    if (n > 31 || n < 1)
    {
        return false;
    }
    return true;

}

int beolvas_feldolgoz(int taborozokSzama, int petiNapok)
{
    int db = 0;
    for (int i = 0; i < taborozokSzama; i++)
    {
        int tEv, tHonap, tNap;
        cin >> tEv >> tHonap >> tNap;
        if (ellenoriz(tEv, tHonap, tNap))
        {
            int taborozoNapok = datumhozNapok(tEv, tHonap, tNap);

            if (abs(petiNapok - taborozoNapok) <= 365)
            {
                db++;
            }
        }
    }

    return db;
}

int main() {

    int taborozokSzama;
    cin >> taborozokSzama;
    if (taborozokSzama > 10000 || taborozokSzama < 1)
    {
        cout << "Hibas táborozószám!" << endl;
        return 0;
    }

    int ev, honap, nap;
    cin >> ev >> honap >> nap;
    if (ellenoriz(ev, honap, nap))
    {
        int petiNapok = datumhozNapok(ev, honap, nap);
        cout << beolvas_feldolgoz(taborozokSzama, petiNapok) << endl;
    }
    else
    {
        cout << "Hibas bemenet!" << endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms316 KiB
2Accepted0/08ms316 KiB
3Accepted5/51ms316 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms316 KiB
6Accepted5/51ms316 KiB
7Accepted5/51ms316 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms316 KiB
10Accepted5/52ms316 KiB
11Accepted5/53ms316 KiB
12Accepted5/53ms316 KiB
13Accepted5/54ms548 KiB
14Accepted5/54ms316 KiB
15Accepted5/56ms316 KiB
16Accepted5/57ms472 KiB
17Accepted5/58ms484 KiB