結果

問題 No.2684 折々の色
ユーザー ks2mks2m
提出日時 2024-03-20 22:27:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,740 ms / 2,000 ms
コード長 1,883 bytes
コンパイル時間 3,507 ms
コンパイル使用メモリ 78,864 KB
実行使用メモリ 141,472 KB
最終ジャッジ日時 2024-03-20 22:28:23
合計ジャッジ時間 53,344 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,992 KB
testcase_01 AC 55 ms
53,984 KB
testcase_02 AC 64 ms
54,120 KB
testcase_03 AC 57 ms
54,016 KB
testcase_04 AC 62 ms
54,004 KB
testcase_05 AC 55 ms
53,996 KB
testcase_06 AC 60 ms
53,972 KB
testcase_07 AC 56 ms
53,964 KB
testcase_08 AC 59 ms
54,000 KB
testcase_09 AC 58 ms
54,016 KB
testcase_10 AC 57 ms
54,000 KB
testcase_11 AC 1,226 ms
98,812 KB
testcase_12 AC 777 ms
81,960 KB
testcase_13 AC 938 ms
95,656 KB
testcase_14 AC 741 ms
80,100 KB
testcase_15 AC 842 ms
83,196 KB
testcase_16 AC 319 ms
65,592 KB
testcase_17 AC 747 ms
80,984 KB
testcase_18 AC 994 ms
97,824 KB
testcase_19 AC 1,112 ms
98,868 KB
testcase_20 AC 1,154 ms
88,204 KB
testcase_21 AC 387 ms
67,616 KB
testcase_22 AC 1,077 ms
101,412 KB
testcase_23 AC 850 ms
87,116 KB
testcase_24 AC 479 ms
71,100 KB
testcase_25 AC 737 ms
79,220 KB
testcase_26 AC 1,033 ms
96,240 KB
testcase_27 AC 810 ms
81,336 KB
testcase_28 AC 987 ms
84,740 KB
testcase_29 AC 1,599 ms
122,544 KB
testcase_30 AC 1,414 ms
123,016 KB
testcase_31 AC 1,324 ms
116,616 KB
testcase_32 AC 1,657 ms
129,984 KB
testcase_33 AC 1,644 ms
122,036 KB
testcase_34 AC 1,336 ms
119,584 KB
testcase_35 AC 1,368 ms
122,560 KB
testcase_36 AC 1,339 ms
113,108 KB
testcase_37 AC 1,283 ms
117,448 KB
testcase_38 AC 1,662 ms
136,212 KB
testcase_39 AC 1,691 ms
138,332 KB
testcase_40 AC 1,707 ms
139,044 KB
testcase_41 AC 1,472 ms
133,648 KB
testcase_42 AC 1,493 ms
131,888 KB
testcase_43 AC 1,546 ms
141,472 KB
testcase_44 AC 1,448 ms
139,744 KB
testcase_45 AC 1,640 ms
138,400 KB
testcase_46 AC 1,740 ms
133,924 KB
testcase_47 AC 57 ms
53,984 KB
testcase_48 AC 56 ms
53,984 KB
testcase_49 AC 56 ms
53,980 KB
testcase_50 AC 55 ms
51,924 KB
testcase_51 AC 56 ms
53,992 KB
testcase_52 AC 55 ms
54,004 KB
testcase_53 AC 56 ms
54,000 KB
testcase_54 AC 56 ms
53,992 KB
testcase_55 AC 58 ms
54,004 KB
testcase_56 AC 56 ms
53,992 KB
testcase_57 AC 53 ms
53,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = Integer.parseInt(sa[i]) * 10000;
		}
		int[][] c = new int[n][m];
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < m; j++) {
				c[i][j] = Integer.parseInt(sa[j]);
			}
			t[i] = Integer.parseInt(sa[m]);
		}
		br.close();

		String[] keys = new String[n];
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < m; j++) {
				sb.append(t[i] * c[i][j]).append('-');
			}
			String s = sb.toString();
			keys[i] = s;
			map.put(s, map.getOrDefault(s, 0) + 1);
		}

		for (int i = 0; i < n; i++) {
			boolean flg = true;
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < m; j++) {
				int v1 = x[j] - 100 * t[i] * c[i][j];
				int v2 = 100 - t[i];
				if (v2 == 0) {
					if (v1 != 0) {
						flg = false;
						break;
					}
				} else {
					if (v1 % v2 != 0) {
						flg = false;
						break;
					}
					sb.append(v1 / v2).append('-');
				}
			}
			if (flg) {
				if (t[i] == 100) {
					System.out.println("Yes");
					return;
				}
				String s = sb.toString();
				if (s.equals(keys[i])) {
					if (map.getOrDefault(s, 0) >= 2) {
						System.out.println("Yes");
						return;
					}
				} else {
					if (map.containsKey(s)) {
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
}
0