結果

問題 No.607 開通777年記念
ユーザー CELICACELICA
提出日時 2020-09-23 09:27:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 165,476 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 21:57:57
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0