結果

問題 No.112 ややこしい鶴亀算
ユーザー リチウム
提出日時 2014-12-24 00:10:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 3,938 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 52,912 KB
最終ジャッジ日時 2024-06-12 04:38:53
合計ジャッジ時間 8,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class LightSwitchingPuzzle {
	
	
	 public static void main(String[] args) {
		 Scanner sc=new Scanner(System.in);
		 TreeSet<Integer>asi=new TreeSet<>();
		 int n=sc.nextInt();
		 for(int i=0;i<n;i++){
			 asi.add(sc.nextInt());
		 }
		 if(asi.size()==2){
			 int f=asi.first()+4;
			 int kame=(f-2*n)/2;
			 int turu=n-kame;
			 System.out.println(turu+" "+kame);
		/*2x+2y=2n
		2x+4y=f		 
        2y=f-2n*/
		 }
		 else {
			 int f=asi.first();
			 if(n*4==f+4)System.out.println(0+" "+n);
			 else System.out.println(n+" "+0);
		 }
	 

}
}
0