結果

問題 No.43 野球の試合
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-23 18:15:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,024 bytes
コンパイル時間 2,034 ms
コンパイル使用メモリ 73,776 KB
実行使用メモリ 57,628 KB
最終ジャッジ日時 2023-09-18 08:36:40
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,112 KB
testcase_01 AC 118 ms
55,864 KB
testcase_02 AC 122 ms
55,592 KB
testcase_03 AC 121 ms
56,112 KB
testcase_04 AC 120 ms
55,604 KB
testcase_05 AC 120 ms
56,048 KB
testcase_06 WA -
testcase_07 AC 124 ms
55,880 KB
testcase_08 AC 122 ms
56,108 KB
testcase_09 AC 123 ms
56,404 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        boolean[][] d = new boolean[n][n];
        String[] s = new String[n];
        int[] game = new int[n];
        int[] win = new int[n];
        int tgame=0;
        for(int i=0; i<n; i++){
            s[i]=koko.next();
            for(int j=0; j<n; j++){
                if(s[i].charAt(j)=='o'){
                    d[i][j]=true;
                    win[i]++;
                    game[i]++;
                }else if(s[i].charAt(j)=='-'){
                    
                }else{
                    d[i][j]=true;
                    game[i]++;
                }
            }
            tgame=tgame+game[i];
        }
        if(game[0]<n){
            for(int i=1; i<n; i++){
                if(!d[0][i]){
                    d[0][i]=true;
                    d[i][0]=true;
                    win[0]++;
                    tgame+=2;
                }
            }
        }
        while(tgame<n*n){
            for(int i=2; i<n; i++){
                for(int j=1; j<i; j++){
                    if(!d[i][j]){
                        d[i][j]=true;
                        d[j][i]=true;
                        if(win[i]==win[0]){
                            win[j]++;
                        }else{
                            win[i]++;
                        }
                        tgame+=2;
                    }
                }
            }
        }
        int point = win[0];
        Arrays.sort(win);
        int rank =1;
        int now = win[n-1];
        if(win[n-1]==point){
            System.out.println(rank);
        }else{
            for(int i=n-2; i>=0; i--){
                if(win[i]!=win[i+1]){
                    rank++;
                }
                if(win[i]==point){
                    System.out.println(rank);
                    break;
                }
            }
        }
    }
}
0