結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Mishan5055
提出日時 2020-02-25 17:37:15
言語 Java
(openjdk 23)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,356 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 78,620 KB
実行使用メモリ 78,568 KB
最終ジャッジ日時 2024-10-13 12:27:24
合計ジャッジ時間 13,220 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 TLE * 2 -- * 5
権限があれば一括ダウンロードができます

ソースコード

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