結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Mishan5055Mishan5055
提出日時 2020-02-25 17:53:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,291 bytes
コンパイル時間 2,641 ms
コンパイル使用メモリ 78,268 KB
実行使用メモリ 65,888 KB
最終ジャッジ日時 2024-04-21 13:52:17
合計ジャッジ時間 13,765 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
46,744 KB
testcase_01 AC 129 ms
41,328 KB
testcase_02 AC 140 ms
41,268 KB
testcase_03 AC 139 ms
41,244 KB
testcase_04 AC 124 ms
39,980 KB
testcase_05 AC 138 ms
41,144 KB
testcase_06 AC 141 ms
41,656 KB
testcase_07 AC 139 ms
41,460 KB
testcase_08 AC 142 ms
41,584 KB
testcase_09 AC 142 ms
41,368 KB
testcase_10 WA -
testcase_11 AC 1,209 ms
60,124 KB
testcase_12 TLE -
testcase_13 AC 1,031 ms
59,752 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[] Binv=new int[M];
        
        for(int i=0;i<M;i++){
            pq.add(sc.nextInt());
        }

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

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