blob: bea4b05717140a2d323446e20618c0464c184415 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
)
func main() {
f, err := os.Open("input")
if err != nil {
log.Fatalf("%+v", err)
}
defer f.Close()
scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanLines)
scanner.Scan()
A, err := strconv.Atoi(scanner.Text())
if err != nil {
log.Fatalf("%+v", err)
}
scanner.Scan()
B, err := strconv.Atoi(scanner.Text())
if err != nil {
log.Fatalf("%+v", err)
}
A += B
scanner.Scan()
C, err := strconv.Atoi(scanner.Text())
if err != nil {
log.Fatalf("%+v", err)
}
B += C
A += C
result := 0
for scanner.Scan() {
D, err := strconv.Atoi(scanner.Text())
if err != nil {
log.Fatalf("%+v", err)
}
C += D
B += D
if B > A {
result++
}
A = B
B = C
C = D
}
fmt.Println(result)
}
|