Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var num, v1, v2, currentValue, currentDiff int
- fmt.Scanln(&num)
- fmt.Scanln(&v1)
- fmt.Scanln(&v2)
- var equalValue = v1 + v2
- var maxDiff = 0
- for i := 1; i < num; i++ {
- fmt.Scanln(&v1)
- fmt.Scanln(&v2)
- currentValue = v1 + v2
- currentDiff = int(math.Abs(float64(equalValue) - float64(currentValue)))
- if currentDiff > maxDiff {
- maxDiff = currentDiff
- } else {
- equalValue = currentValue
- }
- }
- if maxDiff == 0 {
- fmt.Printf("Yes, value=%d", equalValue)
- } else {
- fmt.Printf("No, maxdiff=%d", maxDiff)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement