結果

問題 No.112 ややこしい鶴亀算
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-03 06:18:36
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,249 bytes
コンパイル時間 3,533 ms
コンパイル使用メモリ 80,628 KB
実行使用メモリ 57,216 KB
最終ジャッジ日時 2023-09-17 03:56:54
合計ジャッジ時間 8,501 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
56,792 KB
testcase_01 AC 141 ms
55,952 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 141 ms
55,788 KB
testcase_05 AC 141 ms
56,096 KB
testcase_06 AC 155 ms
56,552 KB
testcase_07 AC 155 ms
56,380 KB
testcase_08 AC 138 ms
55,756 KB
testcase_09 AC 142 ms
55,824 KB
testcase_10 AC 152 ms
56,920 KB
testcase_11 AC 154 ms
56,364 KB
testcase_12 AC 152 ms
56,524 KB
testcase_13 AC 137 ms
56,696 KB
testcase_14 AC 142 ms
55,572 KB
testcase_15 AC 157 ms
54,920 KB
testcase_16 AC 159 ms
57,016 KB
testcase_17 AC 160 ms
56,540 KB
testcase_18 AC 158 ms
56,684 KB
testcase_19 AC 143 ms
56,096 KB
testcase_20 AC 144 ms
56,048 KB
testcase_21 AC 160 ms
56,792 KB
testcase_22 AC 159 ms
56,704 KB
testcase_23 AC 158 ms
56,964 KB
testcase_24 AC 147 ms
56,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//No.112 ややこしい鶴亀算

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No112 {
    
    static final Scanner sc = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        boolean f = true;
        for (int i=1; i<n; i++) {
            if (a[i] != a[i-1]) f = false;
        }
        if (f) {
            out.println(a[0]/(n-1)==2?(n+" 0"):("0 "+n));
            return;
        }
        int x = 1, y = 0, max = 0;
        for (int i=1; i<n; i++) {
            if (a[0] == a[i]) x++;
            else y++;
            max = max(max,a[i]);
        }
        if (max == a[0]) out.println(x+" "+y);
        else out.println(y+" "+x);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        sc.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0