what is wrong with this??
https://www.codechef.com/viewsolution/21204870
Well, You may have a look at my code
variable m denotes the product, left holds the house number till we have checked and covered, and 100+m+1 is added to check for houses in the end, like 100, 99 …
Rest code is self-explanatory (java)
https://www.codechef.com/viewsolution/15431189
(Solved this for you)
Please UPVOTE…
Feel free to ask anything
If problem related then here , Else than on discuss
My code isnt working despite correct logic. Pls help.
https://www.codechef.com/viewsolution/24481962
I don’t know why i am getting wa. I seriously think my program solves for ever case. please tell me where i am wrong
https://www.codechef.com/viewsolution/25405662
disabling the line:
//std::ios_base::sync_with_stdio(0);
gave AC.
Using std::ios_base::sync_with_stdio(0);
This disables the synchronization between the C and C++ standard streams. By default, all standard streams are synchronized, which in practice allows you to mix C- and C+±style I/O and get sensible and expected results. If you disable the synchronization, then C++ streams are allowed to have their own independent buffers, which makes mixing C- and C+±style I/O an adventure.
Source:
Read it here.
Hope it helps!
Aree waaah…Aap yahaan ??!
yeah, trying to contribute a little.
Nice to see you
Kindly check my solution. I have simply put some mathematics computation to solve this. but somehow it is not working.
https://www.codechef.com/viewsolution/26048253
Kindly let me know, what condition I have missed.
I am new to coding and somehow my code is not accepted . What case i am missing , pls let me know.https://www.codechef.com/viewsolution/26055237
Here’s a simple failing testcase to help you debug:
1
1 9 4
19
… and here’s one for you
1
2 9 1
61 1
Here is an easy O(N) solution in cpp, just by storing the upper and lower bound for each cop we can check if any house is safe or not.(solution)
Thanks. It worked for me.
Hey i dont know why am i getting a wrong answer. Can somebody please help?
https://www.codechef.com/viewsolution/28366715
Here’s a random testcase your solution fails on:
5
10 7 8
20 9 13 10 42 52 43 67 100 74
8 4 1
33 49 27 78 48 30 82 43
3 10 4
12 54 26
2 1 5
7 92
4 3 1
7 1 23 63
Edit:
He solved it.
here, I have applied range update query algorithm. it takes O(100) time complexity.
int a[105]={0};
int m,x,y;
cin>>m>>x>>y;
int i,b;
int s=x*y;
for(i=0; i<m; i++)
{
cin>>b;
int l=max(1,b-s);
int r=min(100+1,b+s+1);
a[l]+=1;
a[r]+=-1;
}
for(i=2; i<=100; i++)
{
a[i]=a[i]+a[i-1];
}
int cnt=0;
for(i=1; i<=100; i++)
{
if(a[i]==0)
cnt++;
}
cout<<cnt<<"\n";
for _ in range(int(input())):
m,x,y = map(int,input().split())
M = list(map(int,input().split()))
s = [1]100
t = xy
for i in range(m):
min = M[i]-t
if(min<0):
min=1
max = M[i]+t
if(max>100):
max = 100
for j in range(min-1,max):
if(s[j]==1):
s[j]=0
t = 0
for k in range(0,100):
if(s[k]==1):
t+=1
print(t)
hey ssjgz can u help me on this one i cant find why i am getting wa