Submission #54118747


Source Code Expand

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] mokuhyouti = new int[M];
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < M; i++) {
            mokuhyouti[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                String key = String.valueOf(j);
                map.put(key, map.getOrDefault(key, 0) + Integer.valueOf(sc.next()));
            }
        }
        boolean ok = true;
        for (int i = 0; i < M; i++) {
            int sesshu = map.getOrDefault(String.valueOf(i), 0);
            int mokuhyou = mokuhyouti[i];
            if (sesshu < mokuhyou) {
                ok = false;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    public static boolean areCoprime(int a, int b) {
        return gcd(a, b) == 1;
    }

    public static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static int lcm(int a, int b) {
        return (a * (b / gcd(a, b)));
    }
}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;

        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;

        }
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Submission Info

Submission Time
Task B - Nutrients
User andrywawa
Language Java (OpenJDK 17)
Score 150
Code Size 3742 Byte
Status AC
Exec Time 84 ms
Memory 37888 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 150 / 150
Status
AC × 2
AC × 25
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand.txt AC 35 ms 33880 KiB
random_01.txt AC 84 ms 37560 KiB
random_02.txt AC 61 ms 35664 KiB
random_03.txt AC 84 ms 37600 KiB
random_04.txt AC 54 ms 35272 KiB
random_05.txt AC 76 ms 37272 KiB
random_06.txt AC 72 ms 36120 KiB
random_07.txt AC 70 ms 36028 KiB
random_08.txt AC 62 ms 36364 KiB
random_09.txt AC 64 ms 36624 KiB
random_10.txt AC 56 ms 35284 KiB
random_11.txt AC 53 ms 35040 KiB
random_12.txt AC 39 ms 34080 KiB
random_13.txt AC 34 ms 33996 KiB
random_14.txt AC 37 ms 34020 KiB
random_15.txt AC 66 ms 37284 KiB
random_16.txt AC 51 ms 34672 KiB
random_17.txt AC 61 ms 36592 KiB
random_18.txt AC 44 ms 34432 KiB
random_19.txt AC 76 ms 37308 KiB
random_20.txt AC 80 ms 37888 KiB
random_21.txt AC 79 ms 36900 KiB
random_22.txt AC 43 ms 34144 KiB
sample_01.txt AC 36 ms 33896 KiB
sample_02.txt AC 36 ms 33724 KiB