95212024-02-22 13:57:08Leventusz09Vásárlás (75 pont)csharpAccepted 75/75149ms57116 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();

            int max = 0, mmax = 0;

            for(int i=0, val; i<N; i++){
                val = A[i] - B[i];
                max = (val + max < val) ? (val + max) : val;
                mmax = (max < mmax) ? (max) : mmax;
                if(val >= 0){
                    //max += val;
                }else{
                    //max = 0;
                }
                /*if (mmax < max){
                    mmax = max;
                }*/
            }
             
            //mmax =  (mmax > 0) ? mmax : 0;

            Console.WriteLine(B.Sum() + ((mmax < 0) ? mmax : 0));
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/034ms22176 KiB
2Accepted0/086ms36412 KiB
3Accepted3/332ms22928 KiB
4Accepted4/430ms23424 KiB
5Accepted4/430ms23472 KiB
6Accepted4/430ms23420 KiB
7Accepted4/437ms24104 KiB
8Accepted3/337ms24304 KiB
9Accepted4/437ms25096 KiB
10Accepted4/437ms25380 KiB
11Accepted4/437ms25316 KiB
12Accepted5/539ms25616 KiB
13Accepted3/3143ms55020 KiB
14Accepted3/3142ms55252 KiB
15Accepted3/3146ms55204 KiB
16Accepted3/3146ms55716 KiB
17Accepted3/3141ms55572 KiB
18Accepted3/3141ms55828 KiB
19Accepted3/3146ms55692 KiB
20Accepted3/3141ms55904 KiB
21Accepted3/3141ms56124 KiB
22Accepted3/3136ms52316 KiB
23Accepted3/3142ms57116 KiB
24Accepted3/3149ms56544 KiB