結果

問題 No.112 ややこしい鶴亀算
ユーザー scache
提出日時 2015-09-19 18:03:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 3,341 ms
コンパイル使用メモリ 78,900 KB
実行使用メモリ 42,672 KB
最終ジャッジ日時 2024-07-19 08:06:54
合計ジャッジ時間 7,883 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main253 {
	public static void main(String[] args) {
		Main253 p = new Main253();
	}

	public Main253() {
//		solve1();
		solve2();
		
	}

	public void solve1() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i=0;i<n;i++){
			count += sc.nextInt();
		}
		
		int total = count/(n-1);
		
		int crane = (total-n*2)/2;
		System.out.println((n-crane) +" " + crane);
	}

	private void solve2(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a= new int[n];
		
		int count = 0;
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			count += a[i];
		}
		
		int total = count/(n-1);
		int crane = 0;
		int kame = 0;
		for(int i=0;i<n;i++){
			crane += total-a[i] == 2 ? 1 : 0;
			kame += total-a[i] == 4 ? 1 : 0;
		}
		
		System.out.println(crane + " " + kame);
	}
}
0