33 lines
576 B
Go
33 lines
576 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
reader := bufio.NewReader(os.Stdin)
|
|
var target int
|
|
if _, err := fmt.Fscan(reader, &target); err != nil {
|
|
os.Exit(2)
|
|
}
|
|
seen := map[int]int{}
|
|
scanner := bufio.NewScanner(reader)
|
|
scanner.Split(bufio.ScanWords)
|
|
for position := 1; scanner.Scan(); position++ {
|
|
value, err := strconv.Atoi(scanner.Text())
|
|
if err != nil {
|
|
os.Exit(2)
|
|
}
|
|
if first, ok := seen[target-value]; ok {
|
|
fmt.Println(first, position)
|
|
return
|
|
}
|
|
if _, ok := seen[value]; !ok {
|
|
seen[value] = position
|
|
}
|
|
}
|
|
}
|