93102024-02-20 12:13:29Leventusz09Leghosszabb nyaralás (75 pont)csharpAccepted 75/7586ms39792 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Leghosszabb_nyaralás{
    class Program{
        static void Main(){
            string[] NP = Console.ReadLine().Split();
            int N = int.Parse(NP[0]);
            int P = int.Parse(NP[1]);
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int o1 = 0, TP = 0;
            for(int i=0, j=0; j<N;){
                if(TP <= P){
                    TP += A[j];
                    j++;
                }else{
                    TP -= A[i];
                    i++;
                }
                if (TP <= P && o1 < j - i) o1 = j - i;
            }
            Console.WriteLine(o1);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/030ms22080 KiB
2Accepted0/082ms36228 KiB
3Accepted3/329ms22656 KiB
4Accepted3/332ms23024 KiB
5Accepted3/330ms23296 KiB
6Accepted3/332ms23468 KiB
7Accepted3/332ms23916 KiB
8Accepted4/430ms24356 KiB
9Accepted4/437ms25508 KiB
10Accepted5/537ms25860 KiB
11Accepted5/541ms27220 KiB
12Accepted5/541ms27616 KiB
13Accepted7/776ms36588 KiB
14Accepted7/782ms38008 KiB
15Accepted7/785ms39192 KiB
16Accepted8/883ms39044 KiB
17Accepted8/886ms39792 KiB