結果

問題 No.112 ややこしい鶴亀算
ユーザー t8m8⛄️
提出日時 2015-04-03 06:14:01
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 3,489 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 57,188 KB
最終ジャッジ日時 2024-07-04 01:35:32
合計ジャッジ時間 8,182 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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