95162024-02-22 13:28:32Leventusz09Vásárlás (75 pont)csharpWrong answer 22/75146ms58744 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 = 0, 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];
                    l++;
                }else{
                    maxi = i + 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 (mmaxi <= i && i < mmaxi + 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
base22/75
1Accepted0/032ms21904 KiB
2Wrong answer0/085ms36440 KiB
3Wrong answer0/332ms22716 KiB
4Accepted4/432ms23124 KiB
5Wrong answer0/432ms23372 KiB
6Accepted4/432ms23760 KiB
7Wrong answer0/437ms24912 KiB
8Wrong answer0/337ms24656 KiB
9Wrong answer0/437ms25664 KiB
10Wrong answer0/437ms25780 KiB
11Wrong answer0/439ms26112 KiB
12Accepted5/539ms26164 KiB
13Accepted3/3141ms57012 KiB
14Wrong answer0/3145ms57700 KiB
15Wrong answer0/3144ms57640 KiB
16Wrong answer0/3145ms57612 KiB
17Wrong answer0/3141ms58132 KiB
18Wrong answer0/3145ms58084 KiB
19Accepted3/3143ms57600 KiB
20Wrong answer0/3140ms58364 KiB
21Wrong answer0/3140ms58628 KiB
22Wrong answer0/3129ms54520 KiB
23Wrong answer0/3146ms58744 KiB
24Accepted3/3143ms58184 KiB