You are not logged in. Please login at to post your questions!


Wrong Answer in Chef and Way

I am getting a WA in all except one test case in the problem CHRL4 (Chef and Way) when submitted to the grader

The link to the problem is:

The link to my solution is:

Can someone help me figure out the problem in this code? Thanks

asked 30 Dec '18, 20:53

shubhamrajsrp's gravatar image

accept rate: 0%

edited 30 Dec '18, 20:54

You can't compare 2 numbers by comparing their modulo with another number. Say you are comparing $500$ and $2$. Obviously $500 \gt 2$ but of you take modulo with, say, $499$. Then you will be comparing $1$ and $2$ and get $1 \lt 2$ but that does not imply that $500 \lt 2$.

You are calculating min(street[max(0,i-k):i]) in your code and each value of street is taken modulo $10^9+7$ and the actual values of street can exceed $10^9+7$ easily.

(31 Dec '18, 01:30) psaini724★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 30 Dec '18, 20:53

question was seen: 72 times

last updated: 31 Dec '18, 01:32