結果

問題 No.112 ややこしい鶴亀算
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-03 06:11:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,241 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 79,268 KB
実行使用メモリ 58,912 KB
最終ジャッジ日時 2023-09-17 03:56:37
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
56,792 KB
testcase_01 AC 122 ms
56,092 KB
testcase_02 AC 125 ms
56,720 KB
testcase_03 AC 133 ms
56,472 KB
testcase_04 AC 122 ms
56,120 KB
testcase_05 AC 120 ms
55,616 KB
testcase_06 AC 129 ms
56,648 KB
testcase_07 AC 127 ms
56,864 KB
testcase_08 AC 120 ms
56,188 KB
testcase_09 AC 121 ms
56,124 KB
testcase_10 AC 140 ms
56,664 KB
testcase_11 AC 155 ms
56,980 KB
testcase_12 AC 127 ms
58,608 KB
testcase_13 AC 121 ms
56,040 KB
testcase_14 AC 126 ms
55,668 KB
testcase_15 AC 134 ms
57,520 KB
testcase_16 WA -
testcase_17 AC 152 ms
57,064 KB
testcase_18 WA -
testcase_19 AC 124 ms
55,800 KB
testcase_20 AC 124 ms
55,932 KB
testcase_21 AC 134 ms
57,260 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 130 ms
56,516 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;
        for (int i=1; i<n; i++) {
            if (a[0] == a[i]) x++;
            else y++;
            if (a[0] < a[i]) {
                int t = x; x = y; y = t;
            }
        }
        out.println(x+" "+y);
    }

    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