# Problem Code: COPS

//my answer is satisfying all input cases but giving wrong answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,x,y;
cin>>n>>x>>y;
int A[n]={0};
int i;
for(i=0;i<n;i++)
{
cin>>A[i];
}
sort(A,A+n);
vectorv1;
v1.push_back(1);
for(i=0;i<n;i++)
{
v1.push_back(A[i]-xy);
v1.push_back(A[i]);
v1.push_back(A[i]+x
y);
}
v1.push_back(100);
int sum=0,count=0;
/for(i=0;i<(v1.size());i++)
cout<<v1[i];
/
if(v1[1]<=100&&(v1[1]-v1[0])>=0)
{
sum+=v1[1]-v1[0];
}
int g=v1.size();
for(i=1;i<g-2;i++)
{
int diff=(v1[i+1]-v1[i]);
if(diff!=x*y&&diff>0&&(v1[i]<=100)&&(v1[i+1]<=100))
{
sum+=diff;
count++;
}
}
if((v1[g-1]<=100)&&(v1[g-2]<=100)&&(v1[g-1]-v1[g-2])>0)
{
sum+=(v1[g-1]-v1[g-2]);
}
cout<<sum-count<<endl;

}
}

Please either format your code or link to your submission - the forum software has mangled it and it won’t compile!

Edit:

Assuming it’s this, consider the testcase:

``````1
8 3 1
41 80 64 2 47 89 5 69
``````

The answer should be `53`.