Better Dice

시간 제한1초메모리 제한1024 MB

요약
두 n면 주사위가 주어질 때 어느 주사위가 더 높은 수를 더 자주 내는지 판정하고, 같으면 무승부를 출력한다.
난이도

쉬움10점 중 3점

유형
정렬, 투 포인터, 배열
정답자
아직 제출이 없습니다

문제

The latest Table-Top Role Playing Game is out now: Better Dice. Unlike all other TTRPGs, this one is all about dice. In fact, it is all about the better die: decisions are made, friendships gained and lost, fights fought, battles won, all based on who has the better die.

This game uses special nn-sided dice where each of the nn faces has the same probability of being rolled. Moreover, each die has its own special set of nn numbers on the faces.

While playing Better Dice you ended up in a very precarious situation where you must absolutely have a better die than your opponent, that is, you must roll higher than your opponent. Given both your die and your opponent's die, decide who is more likely to roll a higher number.

입력

The input consists of:

  • One line with an integer nn (1≤n≤10001\leq n\leq 1000), the number of sides on each die.
  • Two lines, each with nn integers dd (1≤d≤1091 \leq d \leq 10^9), the values on one of the dice.

출력

Output "first" if the first die is more likely to roll a higher number than the second die. Output "second" if the second die is more likely to roll a higher number than the first die. Output "tie" if they are both equally likely to come up higher than the other.

예제3

  1. 예제 1

    입력
    2
    4 6
    5 5
    
    예상 출력
    tie
    
  2. 예제 2

    입력
    6
    1 2 3 4 5 6
    7 6 5 4 3 2
    
    예상 출력
    second
    
  3. 예제 3

    입력
    3
    2 2 2
    1 1 8
    
    예상 출력
    first