結果

問題 No.607 開通777年記念
ユーザー tentententen
提出日時 2020-09-05 21:22:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,628 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 69,760 KB
最終ジャッジ日時 2024-05-06 20:11:02
合計ジャッジ時間 7,658 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
39,888 KB
testcase_01 AC 110 ms
41,556 KB
testcase_02 AC 109 ms
39,716 KB
testcase_03 AC 107 ms
39,752 KB
testcase_04 AC 107 ms
40,684 KB
testcase_05 AC 118 ms
41,284 KB
testcase_06 AC 120 ms
41,024 KB
testcase_07 AC 437 ms
47,844 KB
testcase_08 AC 129 ms
41,504 KB
testcase_09 AC 239 ms
46,232 KB
testcase_10 AC 172 ms
42,124 KB
testcase_11 AC 1,628 ms
69,760 KB
testcase_12 AC 1,131 ms
57,988 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 = 0; i < m; i++) {
    	    int[] sums = new int[n + 1];
    	    for (int j = 1; j <= n; j++) {
    	        arr[j] += sc.nextInt();
    	        sums[j] = sums[j - 1] + arr[j];
    	    }
    	    int right = 0;
    	    for (int left = 0; left < n; left++) {
    	        while (right < n && sums[right] - sums[left] < 777) {
    	            right++;
    	        }
    	        if (sums[right] - sums[left] == 777) {
    	            System.out.println("YES");
    	            return;
    	        }
    	    }
    	}
    	System.out.println("NO");
	}
}
0