結果
問題 | No.607 開通777年記念 |
ユーザー | tokizo |
提出日時 | 2020-02-07 15:34:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 1,415 ms |
コンパイル使用メモリ | 168,376 KB |
実行使用メモリ | 7,524 KB |
最終ジャッジ日時 | 2023-10-25 23:03:55 |
合計ジャッジ時間 | 2,675 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 16 ms
4,592 KB |
testcase_08 | AC | 1 ms
4,348 KB |
testcase_09 | AC | 3 ms
4,348 KB |
testcase_10 | AC | 2 ms
4,348 KB |
testcase_11 | AC | 79 ms
7,524 KB |
testcase_12 | AC | 73 ms
7,524 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int A[m][n] = {}; for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cin >> A[i][j]; } } for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ if(i > 0){ A[i][j] += A[i - 1][j]; } } } bool existed = false; const int NUM = 777; for(int i = 0; i < n; i++){ int right = 0, total = 0; for(int left = 0; left < n; left++){ while(right < n && total + A[i][right] <= NUM){ total += A[i][right]; right++; } if(total == NUM){ existed = true; break; } if(left == right) right++; else total -= A[i][left]; } if(existed) break; } cout << (existed ? "YES" : "NO") << endl; return 0; }