Submission #1664173


Source Code Expand

Copy
import java.io.*;
import java.util.*;

public class Main {
    private FastScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int m = in.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
        }
        Arrays.sort(b);
        int it = 0;
        for (int i = 0; i < m; i++) {
            while (it != n && a[it] < b[i]) {
                it++;
            }
            if (it == n || a[it] != b[i]) {
                out.println("NO");
                return;
            }
            it++;
        }
        out.println("YES");
    }

    private void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    private void runIO() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Submission Info

Submission Time
Task B - Problem Set
User qwerty787788
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 3003 Byte
Status
Exec Time 411 ms
Memory 60512 KB

Test Cases

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
dataset1 100 / 100 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt
dataset2 100 / 100 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt 77 ms 18644 KB
01-02.txt 71 ms 21332 KB
01-03.txt 72 ms 18644 KB
01-04.txt 71 ms 20820 KB
01-05.txt 72 ms 21332 KB
01-06.txt 72 ms 20948 KB
01-07.txt 76 ms 20948 KB
01-08.txt 80 ms 19156 KB
01-09.txt 72 ms 21204 KB
02-01.txt 240 ms 40604 KB
02-02.txt 290 ms 44692 KB
02-03.txt 395 ms 57920 KB
02-04.txt 252 ms 43860 KB
02-05.txt 411 ms 59252 KB
02-06.txt 212 ms 42324 KB
02-07.txt 335 ms 50792 KB
02-08.txt 311 ms 60512 KB
02-09.txt 315 ms 58584 KB
02-10.txt 331 ms 55840 KB
sample-01.txt 70 ms 22996 KB
sample-02.txt 67 ms 17620 KB
sample-03.txt 69 ms 18388 KB
sample-04.txt 70 ms 18772 KB