93092024-02-20 12:00:10Leventusz09Leghosszabb nyaralás (75 pont)csharpWrong answer 17/7586ms41940 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; i<=j && j<N-1;){
                if(TP <= P){
                    if (o1 < j - i) o1 = j - i;
                    j++;
                    TP += A[j];
                }else{
                    TP -= A[i];
                    i++;
                }
            }
            Console.WriteLine(o1+1);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base17/75
1Accepted0/030ms22248 KiB
2Wrong answer0/086ms37032 KiB
3Wrong answer0/330ms23468 KiB
4Wrong answer0/329ms23944 KiB
5Wrong answer0/329ms24176 KiB
6Wrong answer0/332ms24452 KiB
7Wrong answer0/332ms24796 KiB
8Accepted4/430ms24684 KiB
9Wrong answer0/435ms25304 KiB
10Wrong answer0/535ms25664 KiB
11Wrong answer0/539ms27320 KiB
12Accepted5/541ms28176 KiB
13Wrong answer0/779ms37376 KiB
14Wrong answer0/782ms39260 KiB
15Wrong answer0/786ms40740 KiB
16Wrong answer0/883ms41268 KiB
17Accepted8/885ms41940 KiB