結果

問題 No.607 開通777年記念
ユーザー lapilapi
提出日時 2019-06-23 17:55:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,137 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 105,088 KB
実行使用メモリ 7,284 KB
最終ジャッジ日時 2023-08-27 05:08:46
合計ジャッジ時間 2,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int a[1001][1001];

bool C(vector<int> train) {
	int sum = 0; // left <= i < right を満たすtrain[i]の和
	int left = 0, right = 0;
	bool flag = false;

	while(!flag && left < train.size()) {
		while (sum < 777 && right < train.size()) {
			sum += train[right];
			right++;
		}
		if (sum == 777) flag = true;

		sum -= train[left];
		left++;
	}

	return flag;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) cin >> a[i][j];
	}

	vector<int> V(N);

	bool ans = false;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) V[j] += a[i][j];
		if (C(V)) ans = true;
	}

	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}
0