結果

問題 No.989 N×Mマス計算(K以上)
ユーザー silviasetitechsilviasetitech
提出日時 2020-03-05 10:13:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 941 ms / 2,000 ms
コード長 2,197 bytes
コンパイル時間 2,897 ms
コンパイル使用メモリ 79,716 KB
実行使用メモリ 62,108 KB
最終ジャッジ日時 2024-04-22 02:10:06
合計ジャッジ時間 11,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,392 KB
testcase_01 AC 114 ms
41,084 KB
testcase_02 AC 127 ms
41,644 KB
testcase_03 AC 132 ms
41,492 KB
testcase_04 AC 113 ms
40,820 KB
testcase_05 AC 121 ms
41,156 KB
testcase_06 AC 122 ms
41,248 KB
testcase_07 AC 119 ms
40,848 KB
testcase_08 AC 129 ms
41,360 KB
testcase_09 AC 128 ms
41,376 KB
testcase_10 AC 653 ms
51,492 KB
testcase_11 AC 682 ms
51,276 KB
testcase_12 AC 667 ms
57,236 KB
testcase_13 AC 561 ms
49,932 KB
testcase_14 AC 941 ms
62,108 KB
testcase_15 AC 498 ms
48,932 KB
testcase_16 AC 640 ms
50,544 KB
testcase_17 AC 572 ms
49,904 KB
testcase_18 AC 486 ms
49,148 KB
testcase_19 AC 646 ms
54,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        nmCalc solver = new nmCalc();
        solver.solve(1, in, out);
        out.close();
    }

    static class nmCalc {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 愚直だと死んでしまうので二分探索かしゃくとりだけど尺取り法でよさそう…?
            // どっちも出してどっちもACすればええやん!人生は冒険や!
            int n = in.nextInt();
            int m = in.nextInt();
            int k = in.nextInt();
            long ans = 0;
            String op = in.next();
            ArrayList<Long> min2max = new ArrayList<>();
            ArrayList<Long> max2min = new ArrayList<>();
            for (int i = 0; i < m; i++) {
                min2max.add(in.nextLong());
            }
            for (int i = 0; i < n; i++) {
                max2min.add(in.nextLong());
            }

            min2max.sort(Comparator.naturalOrder());
            max2min.sort(Comparator.reverseOrder());
            int index = 0;
            for (Long l : min2max) {
                while (index < n) {
                    if (op.charAt(0) == '+') {
                        if (l + max2min.get(index) < k) {
                            break;
                        }
                    } else if (op.charAt(0) == '*') {
                        if (l * max2min.get(index) < k) {
                            break;
                        }
                    }
                    index++;
                }
                ans += index;
                // out.println(ans);
            }
            out.println(ans);

        }

    }
}

0