結果

問題 No.607 開通777年記念
ユーザー Mcpu3Mcpu3
提出日時 2018-12-26 11:58:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 68,792 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 02:53:22
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,948 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 2 ms
6,948 KB
testcase_07 AC 13 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 4 ms
6,948 KB
testcase_10 AC 2 ms
6,948 KB
testcase_11 AC 211 ms
6,948 KB
testcase_12 AC 216 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int M, sum, tmp, i;
	size_t N, left, right;
	cin >> N >> M;
	vector<int> a(N);
	for (i = 0; i < M; ++i) {
		sum = 0;
		right = 0;
		for (size_t j = 0; j < N; ++j) {
			cin >> tmp;
			a[j] += tmp;
		}
		for (left = 0; left < N; ++left) {
			while (right < N && sum + a[right] <= 777) {
				sum += a[right];
				++right;
			}
			if (sum == 777) break;
			if (left == right) ++right;
			else sum -= a[left];
		}
		if (left != N) break;
	}
	if (i != M) cout << "YES";
	else cout << "NO";
}
0