|  | 
|  | 
| back to board | решение С# using System;using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
 namespace РџРѕРІРѕСЂРѕС‚
 {
 class Program
 {
 static void Main(string[] args)
 {
 string[] mas = Console.ReadLine().Split(' ');
 int k = int.Parse(mas[0]);
 int n = int.Parse(mas[1]);
 int[] A = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray();
 int M = 0;
 for (int i = 0; i < n; i++)
 {
 M += A[i];
 if (M - k >= 0)
 {M -= k;}
 else
 {M = 0;}
 }
 Console.WriteLine(M);
 }
 }
 }
 Надеюсь понятно всё.
 | 
 | 
|