×

# Same Logic Written, but one is wrong answer

 0 Hi All, I am new to codechef, Yesterday I solved my first question in codechef. I have one doubt. Yesterday I solved Following Question (https://www.codechef.com/problems/LECANDY). There are two solutions which I tried, From my point of view both answer are correct, but in codechef first answer codechef is not accepting by giving me wrong_anser as output, but for second answer codechef accepted my answer, I need a reason why it is happening while both answers are correct. *Note - I am using GOLANG as my Programming Language. First Solution - Not Accepted BY CodeChef package main import ( "fmt" ) func main() { T := 0 fmt.Scan(&T) for i := 0; i < T; i++ { N, C := 0, 0 fmt.Scan(&N, &C) for j := 0; j < N; j++ { Temp := 0 fmt.Scan(&Temp) C -= Temp } if C < 0 { fmt.Println("No") } else { fmt.Println("Yes") } } } Second Solution - Accepted By COdechef package main import ( "fmt" ) func main() { T := 0 SUM := 0 fmt.Scan(&T) for i := 0; i < T; i++ { N, C := 0, 0 fmt.Scan(&N, &C) for j := 0; j < N; j++ { Temp := 0 fmt.Scan(&Temp) SUM = SUM + Temp } if SUM > C { fmt.Println("No") } else { fmt.Println("Yes") } } } asked 19 Aug '18, 14:26 1●1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×1,615
×836
×9

question asked: 19 Aug '18, 14:26

question was seen: 54 times

last updated: 19 Aug '18, 14:30