結果

問題 No.112 ややこしい鶴亀算
ユーザー 練習生
提出日時 2015-08-22 10:39:44
言語 Java
(openjdk 23)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 2,939 ms
コンパイル使用メモリ 85,228 KB
実行使用メモリ 46,484 KB
最終ジャッジ日時 2024-07-18 12:37:49
合計ジャッジ時間 7,127 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class No112 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int case1 = sc.nextInt(), case2 = 0;
		int case1Count = 1, case2Count = 0;
		int turu = 0, kame = 0;
		for(int i = 0; i < (n - 1); i++){
			int inputData = sc.nextInt();
			if(inputData == case1){
				case1Count++;
			}else{
				case2 = inputData;
				case2Count++;
			}
		}
		sc.close();
		if(case2 == 0){
			if(((n * 2) - 2) == case1){
				turu = case1Count;
			}else{
				kame = case1Count;
			}			
		}else if(case1 > case2){
			turu = case1Count;
			kame = case2Count;
		}else{
			turu = case2Count;
			kame = case1Count;
		}
		System.out.println(turu + " " + kame);
	}
}
0