結果

問題 No.112 ややこしい鶴亀算
ユーザー t8m8⛄️
提出日時 2015-04-03 06:18:36
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,249 bytes
コンパイル時間 3,847 ms
コンパイル使用メモリ 80,384 KB
実行使用メモリ 55,036 KB
最終ジャッジ日時 2024-07-04 01:36:03
合計ジャッジ時間 7,842 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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