Last active
July 6, 2016 06:17
-
-
Save alejandrorangel/615615fdc3ddc5b1294b7614d69915c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" | |
) | |
func main() { | |
reader := bufio.NewReader(os.Stdin) | |
testCasesString, _ := reader.ReadString('\n') | |
//fmt.Println(testCasesString) | |
testCases, err := strconv.Atoi(strings.TrimSpace(testCasesString)) | |
if err != nil { | |
fmt.Printf("%d\t%v\n", testCases, err) | |
} | |
for index := 0; index < testCases; index++ { | |
counter := 0 | |
infoString, _ := reader.ReadString('\n') | |
infoString = strings.TrimSpace(infoString) | |
info := strings.Split(infoString, " ") | |
//amoutOfStudents := strconv.Atoi(info[0]) | |
amoutOfStudents, err := strconv.Atoi(info[0]) | |
if err != nil { | |
fmt.Println(err) | |
} | |
//threshold := strconv.Atoi(info[1]) | |
threshold, err := strconv.Atoi(info[1]) | |
if err != nil { | |
fmt.Println(err) | |
} | |
studentsString, _ := reader.ReadString('\n') | |
studentsString = strings.TrimSpace(studentsString) | |
students := strings.Split(studentsString, " ") | |
for i := 0; i < amoutOfStudents; i++ { | |
//fmt.Println(students[i]) | |
student, err := strconv.Atoi(students[i]) | |
if err != nil { | |
fmt.Println(err) | |
} | |
if student > 0 { | |
counter++ | |
} | |
} | |
if (len(students) - counter) < threshold { | |
fmt.Println("YES") | |
} else { | |
fmt.Println("NO") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment