#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n,x,y;
cin>>n>>x>>y;
int arr[n]={0};
for(int i=0;i<n;i++){
cin>>arr[i];
}
int count=0;
//int house[100]={0};
for(int i=0;i<n;i++){
for(int j=arr[i];j<=100&&j<=arr[i]+x*y;j++){
count++;
}
for(int j=arr[i];j>0&&j>=arr[i]-x*y;j--){
count++;
}
}
cout<<100-count<<endl;
}
return 0;
}
// ques link COPS Problem - CodeChef
sudo_s
July 12, 2021, 1:56pm
2
tanuj_gupta:
#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n,x,y;
cin>>n>>x>>y;
int arr[n]={0};
for(int i=0;i<n;i++){
cin>>arr[i];
}
int count=0;
//int house[100]={0};
for(int i=0;i<n;i++){
for(int j=arr[i];j<=100&&j<=arr[i]+x*y;j++){
count++;
}
for(int j=arr[i];j>0&&j>=arr[i]-x*y;j--){
count++;
}
}
cout<<100-count<<endl;
}
return 0;
}
Use test case
1
2 10 10
30 40
Your Output: -102
Expected Output: 0
Hint: You are ignoring the fact that multiple cops can check the same house.
P.S: Format your code by wrapping your code inside ```