59332023-10-05 21:16:32rennVállalkozócsharpRuntime error 0/4016ms3152 KiB
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class Program
    {
        static Random rn = new Random();

        static void Main(string[] args)
        {
            string[] be = Console.ReadLine().Split(' ');
            int N = int.Parse(be[0]), M = int.Parse(be[1]), jo = 0;

            int[] napok = new int[N+1];
            int[] munkak = new int[N];

            be = Console.ReadLine().Split(' ');
            for (int i = 0, j; i < N; i++)
            {
                napok[i] = int.Parse(be[i]);
                munkak[i] = 0;
            }

            for (int i = 0, j; i < M; i++)
            {
                j = int.Parse(Console.ReadLine());
                munkak[j - 1]++;
            }

            for (int i = 0; i < N; i++)
            {
                jo += Math.Min(napok[i], munkak[i]);
                napok[i + 1] += Math.Max(0, napok[i] - munkak[i]);
            }

            Console.WriteLine(jo);
            //Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Runtime error0/016ms2820 KiB
2Runtime error0/014ms3036 KiB
3Runtime error0/216ms2824 KiB
4Runtime error0/216ms2820 KiB
5Runtime error0/216ms3000 KiB
6Runtime error0/214ms2948 KiB
7Runtime error0/214ms2948 KiB
8Runtime error0/214ms2728 KiB
9Runtime error0/214ms2704 KiB
10Runtime error0/216ms2816 KiB
11Runtime error0/214ms2740 KiB
12Runtime error0/214ms3136 KiB
13Runtime error0/214ms3000 KiB
14Runtime error0/214ms2964 KiB
15Runtime error0/216ms2892 KiB
16Runtime error0/214ms2988 KiB
17Runtime error0/214ms2720 KiB
18Runtime error0/214ms2964 KiB
19Runtime error0/216ms2924 KiB
20Runtime error0/214ms3152 KiB
21Runtime error0/214ms2928 KiB
22Runtime error0/214ms2944 KiB