81412024-01-12 14:27:23Boti010Egykorúak (75 pont)csharpElfogadva 75/7556ms31132 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace eletkor
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] P = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] TE = new int[n];
            int[] TH = new int[n];
            int[] TN = new int[n];
            int[] tval = new int[3];
            int Pn = 0;
            int[] OY = { 1950, 1, 1 };
            int[] h = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
            int sz = 0;
            int peti = 0;
            int db = 0;
            for (int i = 0; i < n; i++)
            {
                tval = Console.ReadLine().Split().Select(int.Parse).ToArray();
                TE[i] = tval[0];
                TH[i] = tval[1];
                TN[i] = tval[2];
            }
            Pn = (P[0] - 1950) * 365;
            for (int i = 1950; i < P[0]; i++)
            {
                if (i % 4 ==0)
                {
                    sz++;
                }
            }
            Pn += sz;
            for (int i = 0; i < P[1]; i++)
            {
                Pn += h[i];
            }
            if (P[0] % 4 == 0 && P[1] > 2)
            {
                Pn++;
            }
            Pn += P[2];
            peti = Pn;
            for (int j = 0; j < n; j++)
            {
                Pn = 0;
                P[0] = TE[j];
                P[1] = TH[j];
                P[2] = TN[j];
                Pn = (P[0] - 1950) * 365;
                sz = 0;
                for (int i = 1950; i < P[0]; i++)
                {
                    if (i % 4 == 0)
                    {
                        sz++;
                    }
                }
                Pn += sz;
                for (int i = 0; i < P[1]; i++)
                {
                    Pn += h[i];
                }
                if (P[0] % 4 == 0 && P[1] > 2)
                {
                    Pn++;
                }
                Pn += P[2];
                if (Math.Abs(Pn - peti) <= 365)
                {
                    db++;
                }
                //Console.WriteLine(Pn + " " + peti);
            }
            Console.WriteLine(db);
            Console.ReadKey();
        }
    }
}
 /*for (int i = 0; i < n; i++)
            {
                tval[0] = TE[i];
                tval[1] = TH[i];
                tval[2] = TN[i];
                if (tval[0] % 4 == 0 && tval[1] >= 2)
                {
                    if (tval[2] == 29 || tval[1] > 2)
                    {
                        tval[2]++;
                    }
                    
                }
            }˛*/
RészfeladatÖsszpontTesztVerdiktIdőMemória
base75/75
1Elfogadva0/032ms22428 KiB
2Elfogadva0/056ms28500 KiB
3Elfogadva5/530ms23132 KiB
4Elfogadva5/532ms23532 KiB
5Elfogadva5/530ms23720 KiB
6Elfogadva5/532ms24304 KiB
7Elfogadva5/530ms24128 KiB
8Elfogadva5/532ms24576 KiB
9Elfogadva5/532ms24568 KiB
10Elfogadva5/535ms25724 KiB
11Elfogadva5/535ms26168 KiB
12Elfogadva5/539ms26920 KiB
13Elfogadva5/541ms27168 KiB
14Elfogadva5/543ms28104 KiB
15Elfogadva5/546ms29464 KiB
16Elfogadva5/548ms29972 KiB
17Elfogadva5/554ms31132 KiB