Please read the new rule regarding the restriction on the use of AI tools. ×

prathamesh15kadam's blog

By prathamesh15kadam, history, 20 months ago, In English

I was giving my first contest on codeforces yesterday but I got runtime error in answer I tried to figure our what was causing this but I didn't get anything can anyone please tell me where is the problem. Your help is much appreciated. Here is the link to the question that is "One and Two" -> https://codeforces.me/contest/1788/problem/A. Here is the link to my submission -> https://codeforces.me/contest/1788/submission/192907153

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
20 months ago, # |
  Vote: I like it +3 Vote: I do not like it

https://codeforces.me/contest/1788/submission/192915643

You can check out my implementation .

As array contains only 1 & 2 we just have to count no of 2's. If it is odd then we can't break the array into two sub arrays and if count is even then (count_of_2)/2 --> (let count of 2 is 6 then 3 in each subarray) if all are 1 then print 1 else print -1.Hope this is helpfull to you.

N.B: This might not be the best solution.

Sorry for my bad english...