結果
問題 | No.607 開通777年記念 |
ユーザー |
![]() |
提出日時 | 2020-09-23 09:27:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 809 bytes |
コンパイル時間 | 1,562 ms |
コンパイル使用メモリ | 168,964 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 14:29:56 |
合計ジャッジ時間 | 2,680 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; bool success{ false }; vector<int> a(n, 0); for (int i = 0; i < m; ++i) { for (auto&& it : a) { int aa; cin >> aa; if (aa == 777) { success = true; break; } it += aa; } if (success) break; int right{ 0 }; ll sum{ 0 }; for (int left = 0; left < n; ++left) { while (right < n && sum + a[right] <= 777) sum += a[right++]; if (sum == 777) { success = true; break; } if (left == right) ++right; else sum -= a[left]; } if (success) break; } cout << (success ? "YES" : "NO") << "\n"; return 0; }