結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Mishan5055Mishan5055
提出日時 2020-02-25 18:21:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 988 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 79,460 KB
実行使用メモリ 56,480 KB
最終ジャッジ日時 2024-04-21 13:56:57
合計ジャッジ時間 11,651 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,124 KB
testcase_01 AC 115 ms
40,044 KB
testcase_02 AC 142 ms
41,288 KB
testcase_03 AC 145 ms
41,748 KB
testcase_04 AC 133 ms
41,176 KB
testcase_05 AC 144 ms
41,432 KB
testcase_06 AC 141 ms
41,560 KB
testcase_07 AC 138 ms
41,464 KB
testcase_08 AC 137 ms
41,300 KB
testcase_09 AC 142 ms
41,496 KB
testcase_10 AC 730 ms
49,696 KB
testcase_11 AC 700 ms
49,888 KB
testcase_12 AC 790 ms
53,176 KB
testcase_13 AC 664 ms
49,164 KB
testcase_14 AC 988 ms
56,480 KB
testcase_15 AC 541 ms
48,496 KB
testcase_16 AC 668 ms
49,776 KB
testcase_17 AC 628 ms
49,052 KB
testcase_18 AC 611 ms
48,860 KB
testcase_19 AC 750 ms
49,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int K=sc.nextInt();
        String str=sc.next();
        Integer[] B=new Integer[M];
        Integer[] A=new Integer[N];
        
        for(int i=0;i<M;i++){
            B[i]=sc.nextInt();
        }
      
        Arrays.sort(B,Collections.reverseOrder());
        
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        
        Arrays.sort(A,Collections.reverseOrder());

        long ANS=0;
        int idxB=M-1;
      
        if(str.equals("+")){
            for(int j=0;j<N;j++){
                while(idxB>=0&&B[idxB]+A[j]<K){
                    idxB--;
                }
                ANS+=idxB+1;
            }
        }else{
            for(int j=0;j<N;j++){
                while(idxB>=0&&B[idxB]*A[j]<K){
                    idxB--;
                }
                ANS+=idxB+1;
            }
        }

        System.out.println(ANS);
    }
}
0