結果
問題 | No.607 開通777年記念 |
ユーザー | YamaKasa |
提出日時 | 2018-09-28 01:28:58 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,617 ms / 2,000 ms |
コード長 | 1,570 bytes |
コンパイル時間 | 3,087 ms |
コンパイル使用メモリ | 77,040 KB |
実行使用メモリ | 67,812 KB |
最終ジャッジ日時 | 2024-04-20 09:17:30 |
合計ジャッジ時間 | 9,305 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 144 ms
41,592 KB |
testcase_01 | AC | 139 ms
41,200 KB |
testcase_02 | AC | 145 ms
41,644 KB |
testcase_03 | AC | 141 ms
41,916 KB |
testcase_04 | AC | 139 ms
41,448 KB |
testcase_05 | AC | 142 ms
41,552 KB |
testcase_06 | AC | 146 ms
41,296 KB |
testcase_07 | AC | 849 ms
54,632 KB |
testcase_08 | AC | 148 ms
41,496 KB |
testcase_09 | AC | 266 ms
46,456 KB |
testcase_10 | AC | 277 ms
47,500 KB |
testcase_11 | AC | 1,617 ms
67,592 KB |
testcase_12 | AC | 1,580 ms
67,812 KB |
ソースコード
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 = 1; i <= M; i++) { int right = 0; int sum = 0; for(int left = 0; left < N; left++) { while(right < N && sum < 777) { sum += b[i][right]; right++; } if(sum == 777) { System.out.println("YES"); System.exit(0); } if(left == right) { right++; }else { sum -= b[i][left]; } } } // // 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"); } }