We invite you to participate in CodeChef’s Starters 117, this Wednesday, 17th January, rated for till 5-Stars (ie. for users with rating < 2200).
Time: 8:00 PM — 10:00 PM IST
Joining us on the problem setting panel are:
Setters: Nishank IceKnight1093 Suresh, S.Manuj DarkSparkle Nanthan, croxo.
Tester: Mridul MridulAhi Ahi.
Statement Verifier: Nishank IceKnight1093 Suresh.
Text Editorialist: Nishank IceKnight1093 Suresh.
Contest Admin: Nishank IceKnight1093 Suresh.
Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.
Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.
Hope to see you participating.
Good Luck!
EQUAL2 and A and B are very similar. Other questions were good though.Thanks for the contest.
Notorious coincidence
Thanks for yet Another observe the pattern , find corner cases and code it using if else if else :D !
How to implement sting strings?
Just simulate what was written in the question. Each time someone plays at least 1 character will get deleted, so there will be at most n games for each string.
I used a stack to simulate the game. You can check the code below
It seems that the test-cases for the STINGY ARRAYS Question are very weak. O(N^2) brute force solutions ACs all the test cases.
Can anyone help me to find the solution for problem EQUAL2.
I observed that for difference of A and B is equal X [X = abs(A-B)], let the answer will be Y. Here is a chart,
X = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
Y = [0, 1, 3, 2, 3, 5, 3, 5, 4, 5, 4, 5, 7, 5, 7, 6, 7, 6, 7, 6, 7, 9, 7, 9, 7]
I can't solve this pattern for any difference n. If anyone have free time, please discuss the solution.
https://www.codechef.com/viewsolution/1040425909
Here is the code for EQUAL2 problem
Can you explain why you multiply your abs(n — m) with 8?
If abs(n-m)=10 , take the sqrt of that 8*abs(n-m) gives 8 and add 1 and divide by 2 gives 4. (10 can be expressed by atleast 4 consecutive numbers, 1+2+3+4=10)
If abs(n-m)=11 , take the sqrt of that 8*abs(n-m) gives 9 and add 1 and divide by 2 gives 5. (11 cannot be expressed by 4 consecutive numbers. It should be expressed by atleast 5 consecutive numbers, 1-2+3+4+5=11)
By Logic, If abs(n-m) is odd then ans will be expressed as (k%4==1 or k%4==2) consecutive numbers . Else if abs(n-m) is even then ans will be expressed as (k%4==3 or k%4==0) consecutive numbers where k is an integer.
Can anyone please have a look at my code for today's CodeChef Stingy Arrays problem.
I tried doing stress testing, but couldn't find the failing test case; maybe its an edge case.
explain urs approch .
1
30
2 4 4 4 3 3 3 4 4 4 5 5 4 4 4 2 4 4 4 3 3 3 4 4 4 5 5 4 4 4