95112024-02-22 13:11:41Leventusz09Vásárlás (75 pont)csharpWrong answer 12/75149ms58448 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Vásárlás{
    class Program{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray(),
                  B = Console.ReadLine().Split().Select(int.Parse).ToArray(),
                  O = new int[N];


            int max = 0, maxi = -1, l = 0; 
            int mmax = 0, mmaxi = -1, lmax = 0;

            for(int i=0; i<N; i++){
                O[i] = B[i] - A[i];
                if(O[i] >= 0){
                    max += O[i];
                    if( maxi != i-l-1 ) maxi = i;
                    /*if (maxi == i - 1) {
                    } else {

                    } */
                    l++;
                }else{
                    maxi = -1;
                    max = 0;
                    l = 0;
                }
                if (mmax < max){
                    mmax = max;
                    mmaxi = maxi; 
                    lmax = l;
                }
            }
            int o1 = 0;

            for(int i=0; i<N; i++){
                if (maxi <= i && i < maxi + lmax) o1 += A[i];
                else o1 += B[i];
            }

            /*for(int i=-1, to, j, k; i<N; i++){
                for(j=-1; j<N; j++){
                    to = 0;
                    for(k=0; k<N; k++){
                        if (i <= k && k <= j) to += A[k];
                        else to += B[k];
                    }
                    if (to < o1) o1 = to;
                }
            }*/
            Console.WriteLine(o1); 
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base12/75
1Accepted0/030ms22352 KiB
2Wrong answer0/089ms36836 KiB
3Wrong answer0/332ms22976 KiB
4Wrong answer0/432ms23672 KiB
5Wrong answer0/430ms23536 KiB
6Accepted4/432ms24312 KiB
7Wrong answer0/437ms25340 KiB
8Wrong answer0/335ms25628 KiB
9Wrong answer0/437ms26012 KiB
10Wrong answer0/437ms26448 KiB
11Wrong answer0/437ms26548 KiB
12Accepted5/537ms26888 KiB
13Wrong answer0/3138ms57196 KiB
14Wrong answer0/3140ms57864 KiB
15Wrong answer0/3141ms57760 KiB
16Wrong answer0/3140ms57776 KiB
17Wrong answer0/3140ms57880 KiB
18Wrong answer0/3140ms57932 KiB
19Wrong answer0/3140ms57524 KiB
20Wrong answer0/3138ms57800 KiB
21Wrong answer0/3141ms57832 KiB
22Wrong answer0/3129ms54080 KiB
23Wrong answer0/3149ms58448 KiB
24Accepted3/3146ms58196 KiB