-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDEVU.txt
More file actions
50 lines (49 loc) · 1.3 KB
/
DEVU.txt
File metadata and controls
50 lines (49 loc) · 1.3 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//https://www.codechef.com/problems/COPS
//author : Pravash Ranjan Nayak
import java.util.*;
class Solution
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
int T=ob.nextInt();
while(T-->0)
{
int M=ob.nextInt();
int x=ob.nextInt();
int y=ob.nextInt();
int c=x*y;
int a[]=new int[M];
for(int i=0;i<M;i++)
a[i]=ob.nextInt();
Arrays.sort(a);
int ans=0;int low=-1,high=-1;
for(int i=0;i<M;i++)
{
if(i==0)
{
low=a[i]-c;
high=a[i]+c;
if(low>0)
ans+=low-1;
else
low=Math.max(0,low);
}
else
{
int low2=a[i]-c;
int high2=a[i]+c;
if(high<low2)
{
ans+=low2-high-1;
low=low2;
}
high=high2;
}
}
if(high<100)
ans+=100-high;
System.out.println(ans);
}
}
}