46212023-03-30 12:25:41TortelliniJrLeghosszabb nyaralás (75 pont)csharpWrong answer 3/7576ms37720 KiB
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int p = int.Parse(input[1]);

        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        int longest_stay = 0, current_stay = 0;
        int start = 0, end = 0, budget = p;

        while (end < n)
        {
            if (budget >= a[end])
            {
                budget -= a[end];
                current_stay++;
                end++;
            }
            else if (start == end)
            {
                start++;
                end++;
            }
            else
            {
                budget += a[start];
                current_stay--;
                start++;
            }

            if (current_stay > longest_stay)
            {
                longest_stay = current_stay;
            }

            Console.WriteLine(longest_stay);

            return;
        }
    }
}

SubtaskSumTestVerdictTimeMemory
base3/75
1Wrong answer0/027ms20636 KiB
2Wrong answer0/076ms34676 KiB
3Wrong answer0/327ms21228 KiB
4Wrong answer0/328ms21520 KiB
5Wrong answer0/328ms21992 KiB
6Wrong answer0/328ms22256 KiB
7Accepted3/328ms22284 KiB
8Wrong answer0/428ms22704 KiB
9Wrong answer0/432ms23128 KiB
10Wrong answer0/532ms23668 KiB
11Wrong answer0/537ms24996 KiB
12Wrong answer0/537ms25240 KiB
13Wrong answer0/771ms34484 KiB
14Wrong answer0/774ms36140 KiB
15Wrong answer0/775ms37252 KiB
16Wrong answer0/875ms36956 KiB
17Wrong answer0/875ms37720 KiB