Logo
(追記) (追記ここまで)

5751번 - Head or Tail 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB105486381382.454%

문제

John and Mary have been friends since nursery school. Since then, they have shared a playful routine: every time they meet, they play Head or Tail with a coin, and whoever wins has the privilege of deciding what they are going to play during the day. Mary always choose Head, and John always choose Tail.

Nowadays they are in college, but continue being truly good friends. Whenever they meet, they still play Head and Tail, and the winner decides which film to watch, or which restaurant to have dinner together, and so on.

Yesterday Mary confided to John that she has been keeping a record of the results of every play since they started, in nursery school. It came as a surprise to John! But since John is studying Computer Science, he decided it was a good opportunity to show Mary his skills in programming, by writing a program to determine the number of times each of them won the game over the years.

입력

The input contains several test cases. The first line of a test case contains a single integer N indicating the number of games played (1 ≤ N ≤ 10000). The following line contains N integers Ri, separated by space, describing the list of results. If Ri = 0 it means Mary won the ith game, if Ri = 1 it means John won the ith game (1 ≤ i ≤ N). The end of input is indicated by N = 0.

출력

For each test case in the input your program should output a line containing the sentence “Mary won X times and John won Y times”, where X ≥ 0 and Y ≥ 0.

제한

예제 입력 1

5
0 0 1 0 1
6
0 0 0 0 0 1
0

예제 출력 1

Mary won 3 times and John won 2 times
Mary won 5 times and John won 1 times

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > South America Regional Contests 2005 연습 세션 PA번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /