Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- )
- func output(result string) {
- fmt.Println(result)
- f, _ := os.Create("output.txt")
- defer f.Close()
- f.WriteString(result)
- }
- func main() {
- file, _ := os.Open("input.txt")
- defer file.Close()
- scanner := bufio.NewScanner(file)
- scanner.Split(bufio.ScanWords)
- scanner.Scan()
- target, _ := strconv.Atoi(scanner.Text())
- m := make(map[int]struct{})
- for scanner.Scan() {
- num, _ := strconv.Atoi(scanner.Text())
- if num > target {
- continue
- }
- if _, found := m[target-num]; found {
- output("1")
- return
- }
- m[num] = struct{}{}
- }
- output("0")
- }
Advertisement
Add Comment
Please, Sign In to add comment