結果

問題 No.607 開通777年記念
ユーザー htensaihtensai
提出日時 2019-11-14 13:10:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,417 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 77,536 KB
実行使用メモリ 72,368 KB
最終ジャッジ日時 2023-10-21 19:58:21
合計ジャッジ時間 7,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
57,500 KB
testcase_01 AC 125 ms
57,388 KB
testcase_02 AC 126 ms
57,476 KB
testcase_03 AC 120 ms
57,440 KB
testcase_04 AC 121 ms
57,592 KB
testcase_05 AC 125 ms
57,348 KB
testcase_06 AC 112 ms
56,116 KB
testcase_07 AC 431 ms
61,628 KB
testcase_08 AC 135 ms
57,608 KB
testcase_09 AC 251 ms
61,116 KB
testcase_10 AC 140 ms
57,464 KB
testcase_11 AC 1,374 ms
72,320 KB
testcase_12 AC 1,417 ms
72,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt() + arr[i - 1];
		}
		if (check(arr)) {
		    System.out.println("YES");
		    return;
		}
		for (int i = 1; i < m; i++) {
		    int sum = 0;
		    for (int j = 1; j <= n; j++) {
		        int x = sc.nextInt();
		        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++) {
	        for (int j = 0; j < i; j++) {
	            if (arr[i] - arr[j] == 777) {
	                return true;
	            }
	        }
	    }
	    return false;
	}
}
0