結果

問題 No.607 開通777年記念
ユーザー tentententen
提出日時 2020-09-05 21:18:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,274 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 4,465 ms
コンパイル使用メモリ 72,664 KB
実行使用メモリ 65,064 KB
最終ジャッジ日時 2023-08-19 13:05:48
合計ジャッジ時間 10,416 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,672 KB
testcase_01 AC 121 ms
55,984 KB
testcase_02 AC 126 ms
55,704 KB
testcase_03 AC 120 ms
55,936 KB
testcase_04 AC 126 ms
55,904 KB
testcase_05 AC 121 ms
55,608 KB
testcase_06 AC 125 ms
55,900 KB
testcase_07 AC 414 ms
60,332 KB
testcase_08 AC 135 ms
55,920 KB
testcase_09 AC 243 ms
60,008 KB
testcase_10 AC 146 ms
56,016 KB
testcase_11 AC 1,274 ms
62,928 KB
testcase_12 AC 1,248 ms
65,064 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++) {
    	    for (int j = 1; j <= n; j++) {
    	        arr[j] += sc.nextInt();
    	    }
    	    int[] sums = new int[n + 1];
    	    for (int j = 1; j <= n; j++) {
    	        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