79652024-01-12 09:17:51TortelliniJrBenzinkút üzemeltetés (55)csharpWrong answer 0/5537ms25500 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace benzinkut
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp[0];
            int min = inp[1];
            int[] helyk = new int[n];
            int[] stonks = new int[n];
            int[] ovr = new int[n];
            for (int f = 0; f < n; f++)
            {
                inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                helyk[f] = inp[0];
                stonks[f] = inp[1];
            }
            int max = helyk[n - 1];
            int i = n - 1;
            while (helyk[i] > max - min)
            {
                ovr[i] = stonks[i];
                i--;
            }
            int locmax = 0;
            for (int f = i; f >= 0; f--)
            {
                for (int k = 1; k < n - f; k++)
                {
                    if (helyk[f + k] >= helyk[f] + min && ovr[f + k] > locmax)
                    {
                        locmax = ovr[f + k];
                    }
                }
                ovr[f] = locmax + stonks[f];
                locmax = 0;
            }
            Console.WriteLine(ovr.Max());
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/034ms21996 KiB
2Wrong answer0/037ms22948 KiB
3Wrong answer0/332ms22740 KiB
4Wrong answer0/332ms22964 KiB
5Wrong answer0/332ms23440 KiB
6Wrong answer0/332ms23512 KiB
7Wrong answer0/332ms23832 KiB
8Wrong answer0/332ms24292 KiB
9Wrong answer0/334ms24332 KiB
10Wrong answer0/332ms24460 KiB
11Wrong answer0/332ms24904 KiB
12Wrong answer0/335ms25072 KiB
13Wrong answer0/435ms25184 KiB
14Wrong answer0/435ms25240 KiB
15Wrong answer0/535ms25388 KiB
16Wrong answer0/637ms25500 KiB
17Wrong answer0/635ms25452 KiB