앨리스와 밥은 코딩문제를 풀고 있다. 리뷰어는 앨리스와 밥이 제출한 코드를 clarity, originality, difficulty 3개의 카테고리에서 점수를 준다. 점수는 1에서 100까지다.
앨리스의 점수는
밥의 점수는
로 정의 할 수 있을 것이다. 이제 각 카테고리의 점수를 비교해서 포인트를 더한다.
만약 ai > bi 이면 앨리스가 1 포인트를 가진다.
만약 ai < bi 이면 밥이 1 포인트를 가진다.
만약 ai = bi 이면 누구도 포인트를 가지지 않는다.
이 둘의 포인트를 출력한다.
입력 형식
첫번째 줄에서 앨리스의 3개 카테고리의 점수를 입력한다. 각 점수는 공백문자(white space)로 구분한다.
두번째 줄에서 밥의 3개 카테고리의 점수를 입력한다. 각 점수는 공백문자(white space)로 구분한다.
출력 형식
앨리스와 밥의 포인트를 공백으로 구분해서 하나의 줄에 출력한다.
입력 예제
5 6 7
3 7 10
출력 예제
1 2
문제풀이
golang
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func solve(a []string) {
a1 := a[:3]
a2 := a[3:6]
score := []int{0, 0}
for i := 0; i < 3; i++ {
i1, _ := strconv.Atoi(a1[i])
i2, _ := strconv.Atoi(a2[i])
if i1 > i2 {
score[0]++
}
if i2 > i1 {
score[1]++
}
}
fmt.Printf("%d %d\n", score[0], score[1])
}
func main() {
reader := bufio.NewReader(os.Stdin)
items := []string{}
for i := 0; i < 2; i++ {
txt, _, _ := reader.ReadLine()
d := strings.Split(string(txt), " ")
items = append(items, d...)
}
solve(items)
}
python
#!/bin/python
def solve(ar):
point=[0,0]
a1 = ar[0]
a2 = ar[1]
for i in range(0,3):
if int(a1[i]) > int(a2[i]):
point[0] = point[0]+1
if int(a1[i]) < int(a2[i]):
point[1] = point[1]+1
print point[0], point[1]
ar=[]
for i in range(0,2):
ar.append(raw_input().split(' '))
solve(ar)
Compare the Triplets
문제
- 만약 ai > bi 이면 앨리스가 1 포인트를 가진다.
- 만약 ai < bi 이면 밥이 1 포인트를 가진다.
- 만약 ai = bi 이면 누구도 포인트를 가지지 않는다.
이 둘의 포인트를 출력한다.입력 형식
출력 형식
입력 예제
출력 예제
문제풀이
golang
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func solve(a []string) { a1 := a[:3] a2 := a[3:6] score := []int{0, 0} for i := 0; i < 3; i++ { i1, _ := strconv.Atoi(a1[i]) i2, _ := strconv.Atoi(a2[i]) if i1 > i2 { score[0]++ } if i2 > i1 { score[1]++ } } fmt.Printf("%d %d\n", score[0], score[1]) } func main() { reader := bufio.NewReader(os.Stdin) items := []string{} for i := 0; i < 2; i++ { txt, _, _ := reader.ReadLine() d := strings.Split(string(txt), " ") items = append(items, d...) } solve(items) }python
#!/bin/python def solve(ar): point=[0,0] a1 = ar[0] a2 = ar[1] for i in range(0,3): if int(a1[i]) > int(a2[i]): point[0] = point[0]+1 if int(a1[i]) < int(a2[i]): point[1] = point[1]+1 print point[0], point[1] ar=[] for i in range(0,2): ar.append(raw_input().split(' ')) solve(ar)Recent Posts
Archive Posts
Tags