結果

問題 No.112 ややこしい鶴亀算
ユーザー btkbtk
提出日時 2017-10-13 14:06:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 760 bytes
コンパイル時間 2,629 ms
コンパイル使用メモリ 78,372 KB
実行使用メモリ 42,728 KB
最終ジャッジ日時 2024-04-28 17:29:22
合計ジャッジ時間 7,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
42,480 KB
testcase_01 AC 147 ms
41,660 KB
testcase_02 AC 159 ms
42,420 KB
testcase_03 AC 160 ms
42,268 KB
testcase_04 AC 148 ms
41,688 KB
testcase_05 AC 149 ms
41,540 KB
testcase_06 AC 158 ms
42,548 KB
testcase_07 AC 159 ms
42,384 KB
testcase_08 AC 133 ms
40,372 KB
testcase_09 AC 131 ms
40,184 KB
testcase_10 AC 156 ms
42,728 KB
testcase_11 AC 160 ms
42,488 KB
testcase_12 AC 158 ms
42,480 KB
testcase_13 AC 146 ms
41,360 KB
testcase_14 AC 155 ms
41,816 KB
testcase_15 AC 162 ms
42,588 KB
testcase_16 AC 163 ms
42,436 KB
testcase_17 AC 162 ms
42,504 KB
testcase_18 AC 144 ms
41,872 KB
testcase_19 AC 149 ms
41,864 KB
testcase_20 AC 155 ms
41,724 KB
testcase_21 AC 162 ms
42,344 KB
testcase_22 AC 162 ms
42,440 KB
testcase_23 AC 167 ms
42,488 KB
testcase_24 AC 153 ms
41,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created by btk on 2017/10/13.
 */
public class Main {
   public static void main(String[] args){
       Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       int[] a = new int[n];
       for (int i = 0; i < n; i++) {
           a[i] = sc.nextInt();
       }
       Arrays.sort(a);
       int front = a[0];
       int back = a[n-1];
       if(front == back){
           if(2*(n-1)==front){
               System.out.println(n+" "+0);
           }
           else{
               System.out.println(0+" "+n);
           }
       }
       else{
           int m = (back-(n-1)*2)/2;
           System.out.println(n-m+" "+m);
       }
       sc.close();
   }
}
0