 Same Logic Written, but one is wrong answer

#1

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”)
}
}
}