結果
問題 | No.607 開通777年記念 |
ユーザー | htensai |
提出日時 | 2019-11-14 13:23:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 583 ms / 2,000 ms |
コード長 | 1,337 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 77,540 KB |
実行使用メモリ | 61,780 KB |
最終ジャッジ日時 | 2023-10-21 19:58:36 |
合計ジャッジ時間 | 4,933 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
52,392 KB |
testcase_01 | AC | 54 ms
53,552 KB |
testcase_02 | AC | 55 ms
53,552 KB |
testcase_03 | AC | 56 ms
53,548 KB |
testcase_04 | AC | 55 ms
53,560 KB |
testcase_05 | AC | 54 ms
53,564 KB |
testcase_06 | AC | 54 ms
53,552 KB |
testcase_07 | AC | 144 ms
57,624 KB |
testcase_08 | AC | 57 ms
53,560 KB |
testcase_09 | AC | 98 ms
55,072 KB |
testcase_10 | AC | 57 ms
53,564 KB |
testcase_11 | AC | 569 ms
61,780 KB |
testcase_12 | AC | 583 ms
61,648 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); int[] arr = new int[n + 1]; String[] second = br.readLine().split(" ", n); for (int i = 1; i <= n; i++) { arr[i] = Integer.parseInt(second[i - 1]) + arr[i - 1]; } if (check(arr)) { System.out.println("YES"); return; } for (int i = 1; i < m; i++) { int sum = 0; String[] line = br.readLine().split(" ", n); for (int j = 1; j <= n; j++) { int x =Integer.parseInt(line[j - 1]); sum += x; arr[j] += sum; } if (check(arr)) { System.out.println("YES"); return; } } System.out.println("NO"); } static boolean check(int[] arr) { for (int i = 1; i < arr.length; i++) { if (arr[i] - arr[i - 1] > 777) { continue; } for (int j = 0; j < i; j++) { if (arr[i] - arr[j] == 777) { return true; } else if (arr[i] - arr[j] < 777) { break; } } } return false; } }