-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
35 lines (25 loc) · 1.04 KB
/
Program.cs
File metadata and controls
35 lines (25 loc) · 1.04 KB
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
32
33
34
35
using System;
using System.Linq;
namespace Service_Lane {
class Program {
public static int[] ServiceLane(int[] width, int[][] cases) {
int[] result = new int[cases.Length];
for (int i = 0; i < cases.Length; i++) {
result[i] = width.Skip(cases[i][0]).Take((cases[i][1] - cases[i][0]) + 1).ToArray().Min();
}
return result;
}
static void Main(string[] args) {
string[] nt = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(nt[0]);
int t = Convert.ToInt32(nt[1]);
int[] width = Array.ConvertAll(Console.ReadLine().Split(' '), widthTemp => Convert.ToInt32(widthTemp));
int[][] cases = new int[t][];
for (int i = 0; i < t; i++) {
cases[i] = Array.ConvertAll(Console.ReadLine().Split(' '), casesTemp => Convert.ToInt32(casesTemp));
}
int[] result = ServiceLane(width, cases);
Console.WriteLine(string.Join("\n", result));
}
}
}