結果

問題 No.216 FAC
ユーザー crazybbb3crazybbb3
提出日時 2017-01-31 22:42:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 2,227 bytes
コンパイル時間 2,984 ms
コンパイル使用メモリ 84,276 KB
実行使用メモリ 50,316 KB
最終ジャッジ日時 2023-08-25 16:44:10
合計ジャッジ時間 5,631 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
50,092 KB
testcase_01 AC 47 ms
49,776 KB
testcase_02 AC 49 ms
48,252 KB
testcase_03 AC 49 ms
49,812 KB
testcase_04 AC 48 ms
49,828 KB
testcase_05 AC 49 ms
49,840 KB
testcase_06 AC 48 ms
50,264 KB
testcase_07 AC 48 ms
50,088 KB
testcase_08 AC 47 ms
50,316 KB
testcase_09 AC 48 ms
49,792 KB
testcase_10 AC 49 ms
49,792 KB
testcase_11 AC 47 ms
49,864 KB
testcase_12 AC 47 ms
49,872 KB
testcase_13 AC 48 ms
49,912 KB
testcase_14 AC 46 ms
49,816 KB
testcase_15 AC 49 ms
49,808 KB
testcase_16 AC 55 ms
50,264 KB
testcase_17 AC 49 ms
49,952 KB
testcase_18 AC 50 ms
49,816 KB
testcase_19 AC 51 ms
49,876 KB
testcase_20 AC 50 ms
50,076 KB
testcase_21 AC 54 ms
49,888 KB
testcase_22 AC 50 ms
50,108 KB
testcase_23 AC 52 ms
49,872 KB
testcase_24 AC 57 ms
50,096 KB
testcase_25 AC 54 ms
50,044 KB
testcase_26 AC 51 ms
49,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {

    void solve() throws IOException {
        int n = ni();
        int[] a = nia(n), b = nia(n);
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.merge(b[i], a[i], (x, y) -> x + y);
        }

        Set<Integer> set = map.keySet();
        if (!set.contains(0)) {
            out.println("NO");
            return;
        }
        for (int x : set) {
            if (x == 0) continue;
            if (map.get(x) > map.get(0)) {
                out.println("NO");
                return;
            }
        }
        out.println("YES");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0