-
Notifications
You must be signed in to change notification settings - Fork 0
/
lisa-workbook.cs
31 lines (31 loc) · 1.12 KB
/
lisa-workbook.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
string[] temp = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(temp[0]);
int k = Convert.ToInt32(temp[1]);
string[] temp2 = Console.ReadLine().Split(' ');
int[] problemsCounts = Array.ConvertAll(temp2,Int32.Parse);
int pageNumber = 1;
int result = 0;
foreach(int p in problemsCounts)
{
int qStart = 0, qEnd = p > k ? k : p;
while(true)
{
//Console.WriteLine(pageNumber + " > " + qStart+ " && " + pageNumber + " <= " + qEnd);
result += pageNumber > qStart && pageNumber <= qEnd ? 1 : 0;
pageNumber++;
qStart = qEnd;
if(qEnd == p)
break;
qEnd = p > qEnd + k ? qEnd + k : p;
}
//Console.WriteLine(result);
}
Console.WriteLine(result);
}
}