結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Mishan5055Mishan5055
提出日時 2020-02-25 17:37:15
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,356 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 75,164 KB
実行使用メモリ 67,296 KB
最終ジャッジ日時 2023-08-03 15:39:48
合計ジャッジ時間 13,748 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,988 KB
testcase_01 AC 117 ms
56,116 KB
testcase_02 AC 128 ms
55,920 KB
testcase_03 AC 130 ms
56,368 KB
testcase_04 AC 123 ms
56,004 KB
testcase_05 AC 125 ms
55,868 KB
testcase_06 AC 125 ms
56,072 KB
testcase_07 AC 126 ms
56,472 KB
testcase_08 AC 126 ms
56,168 KB
testcase_09 AC 133 ms
55,932 KB
testcase_10 AC 1,399 ms
64,668 KB
testcase_11 AC 1,116 ms
66,976 KB
testcase_12 TLE -
testcase_13 AC 902 ms
66,688 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

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();
        PriorityQueue<Integer> pq=new PriorityQueue<>();
        int[] B=new int[M];
        int[] Binv=new int[M];
        
        for(int i=0;i<M;i++){
            pq.add(sc.nextInt());
        }

        long ANS=0L;
        
        if(str.equals("+")){
            for(int i=0;i<M;i++){
                B[M-1-i]=pq.poll();
                Binv[M-1-i]=K-B[M-1-i];
            }
            
            for(int i=0;i<N;i++){
                int A=sc.nextInt();
                for(int j=0;j<M;j++){
                    if(A<Binv[j]){
                        break;
                    }
                    ANS++;
                }
            }
        }else{
            for(int i=0;i<M;i++){
                B[M-1-i]=pq.poll();
                Binv[M-1-i]=(K+B[M-1-i]-1)/B[M-1-i];
            }
            
            for(int i=0;i<N;i++){
                int A=sc.nextInt();
                for(int j=0;j<M;j++){
                    if(A<Binv[j]){
                        break;
                    }
                    ANS++;
                }
            }
        }

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