結果

問題 No.989 N×Mマス計算(K以上)
ユーザー tenten
提出日時 2020-08-25 08:09:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 844 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 2,524 ms
コンパイル使用メモリ 77,788 KB
実行使用メモリ 60,076 KB
最終ジャッジ日時 2024-11-06 11:03:07
合計ジャッジ時間 11,450 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public 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();
        boolean isPlus = (sc.next().charAt(0) == '+');
        int[] colums = new int[m];
        for (int i = 0; i < m; i++) {
            colums[i] += sc.nextInt();
        }
        Arrays.sort(colums);
        int[] rows = new int[n];
        for (int i = 0; i < n; i++) {
            rows[i] = sc.nextInt();
        }
        Arrays.sort(rows);
        int idx = n;
        long sum = 0;
        for (int i = 0; i < m; i++) {
            if (isPlus) {
                while (idx > 0 && rows[idx - 1] + colums[i] >= k) {
                    idx--;
                }
            } else {
                while (idx > 0 && rows[idx - 1]  >= (k + colums[i] - 1) / colums[i]) {
                    idx--;
                }
            }
            sum += n - idx;
        }
        System.out.println(sum);
    }
}
0