59342023-10-05 21:17:22rennVállalkozócsharpAccepted 40/4089ms31588 KiB
using System;

namespace ConsoleApp1
{
    internal class Program
    {
        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
base40/40
1Accepted0/028ms20492 KiB
2Accepted0/089ms28072 KiB
3Accepted2/227ms21092 KiB
4Accepted2/227ms21684 KiB
5Accepted2/228ms21756 KiB
6Accepted2/234ms23168 KiB
7Accepted2/235ms23624 KiB
8Accepted2/228ms22948 KiB
9Accepted2/230ms23616 KiB
10Accepted2/228ms23168 KiB
11Accepted2/229ms23600 KiB
12Accepted2/234ms23892 KiB
13Accepted2/237ms24416 KiB
14Accepted2/235ms24404 KiB
15Accepted2/248ms25860 KiB
16Accepted2/246ms26368 KiB
17Accepted2/254ms27964 KiB
18Accepted2/246ms27148 KiB
19Accepted2/250ms27772 KiB
20Accepted2/257ms28144 KiB
21Accepted2/267ms29596 KiB
22Accepted2/282ms31588 KiB