You are not logged in. Please login at www.codechef.com 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: https://www.codechef.com/problems/CHRL4

The link to my solution is: https://www.codechef.com/viewsolution/22138303

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

asked 30 Dec '18, 20:53

shubhamrajsrp's gravatar image

3★shubhamrajsrp
11
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
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×2,169
×1,070
×16
×3

question asked: 30 Dec '18, 20:53

question was seen: 72 times

last updated: 31 Dec '18, 01:32