結果
問題 | No.607 開通777年記念 |
ユーザー |
![]() |
提出日時 | 2020-02-07 15:34:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 1,457 ms |
コンパイル使用メモリ | 167,644 KB |
実行使用メモリ | 7,348 KB |
最終ジャッジ日時 | 2024-09-25 07:15:52 |
合計ジャッジ時間 | 2,669 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#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; }