結果

問題 No.607 開通777年記念
ユーザー YamaKasaYamaKasa
提出日時 2018-09-27 17:55:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,911 ms / 2,000 ms
コード長 1,190 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 77,088 KB
実行使用メモリ 68,576 KB
最終ジャッジ日時 2024-04-20 09:07:18
合計ジャッジ時間 9,882 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
40,456 KB
testcase_01 AC 133 ms
40,768 KB
testcase_02 AC 141 ms
41,452 KB
testcase_03 AC 138 ms
41,504 KB
testcase_04 AC 135 ms
41,268 KB
testcase_05 AC 137 ms
41,532 KB
testcase_06 AC 138 ms
41,508 KB
testcase_07 AC 1,032 ms
60,176 KB
testcase_08 AC 145 ms
41,080 KB
testcase_09 AC 275 ms
46,976 KB
testcase_10 AC 275 ms
47,308 KB
testcase_11 AC 1,911 ms
68,576 KB
testcase_12 AC 1,893 ms
66,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[][]a = new int[M][N];
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < N; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		scan.close();
		int[][]b = new int[M + 1][N];

		for(int i = 1; i <= M; i++) {
			for(int j = 0; j < N; j++) {
				b[i][j] += b[i - 1][j] + a[i - 1][j];
			}
		}
		int[][]c = new int[M][N + 1];

		for(int i = 0; i < M; i++) {
			for(int j = 1; j <= N; j++) {
				c[i][j] += c[i][j - 1] + b[i + 1][j - 1];
			}
		}

//		for(int i = 0; i <= M; i++) {
//			for(int j = 0; j < N; j++) {
//				System.out.print(b[i][j] + " ");
//			}
//			System.out.println();
//		}
//
//		for(int i = 0; i < M; i++) {
//			for(int j = 0; j <= N; j++) {
//				System.out.print(c[i][j] + " ");
//			}
//			System.out.println();
//		}

		for(int i = 0; i < M; i++) {
			for(int j = 0; j <= N; j++) {
				for(int k = j + 1; k <= N; k++) {
					int t = c[i][k] - c[i][j];
					if(t == 777) {
						System.out.println("YES");
						System.exit(0);
					}
				}
			}
		}
		System.out.println("NO");
	}
}
0