結果

問題 No.112 ややこしい鶴亀算
ユーザー konken0324konken0324
提出日時 2015-09-19 17:27:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 604 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 74,040 KB
実行使用メモリ 57,076 KB
最終ジャッジ日時 2023-09-26 13:45:57
合計ジャッジ時間 7,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
56,956 KB
testcase_01 AC 153 ms
56,916 KB
testcase_02 AC 151 ms
56,636 KB
testcase_03 AC 152 ms
56,436 KB
testcase_04 AC 150 ms
56,716 KB
testcase_05 AC 148 ms
56,604 KB
testcase_06 AC 149 ms
56,688 KB
testcase_07 AC 152 ms
56,612 KB
testcase_08 AC 149 ms
56,748 KB
testcase_09 AC 148 ms
56,808 KB
testcase_10 AC 147 ms
56,288 KB
testcase_11 AC 157 ms
56,880 KB
testcase_12 AC 149 ms
57,076 KB
testcase_13 AC 151 ms
56,260 KB
testcase_14 AC 157 ms
56,520 KB
testcase_15 AC 155 ms
56,564 KB
testcase_16 AC 159 ms
56,580 KB
testcase_17 AC 155 ms
56,820 KB
testcase_18 AC 155 ms
56,544 KB
testcase_19 AC 153 ms
56,424 KB
testcase_20 AC 154 ms
56,752 KB
testcase_21 AC 153 ms
56,228 KB
testcase_22 AC 153 ms
56,248 KB
testcase_23 AC 155 ms
56,548 KB
testcase_24 AC 154 ms
56,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int C1 = stdIn.nextInt();
		int C2 = 0;
		int cou1 = 1;
		int cou2 = 0;
		for (int i = 0; i < n - 1; i++) {
			int in = stdIn.nextInt();
			if (C1 == in) {
				cou1++;
			} else {
				C2 = in;
				cou2++;
			}
		}
		int n2=n*2-2;
		int T=0;
		int K=0;
		if(C2==0){
			if(n2==C1){
				T=cou1;
			}
			else{
				K=cou1;
			}
		}
		else if(C1<C2){
			K=cou1;
			T=cou2;
		}
		else{
			T=cou1;
			K=cou2;
		} 
		System.out.println(T+" "+K);
	}
}
0