結果
| 問題 | No.607 開通777年記念 | 
| コンテスト | |
| ユーザー |  lapi | 
| 提出日時 | 2019-06-23 17:55:35 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 86 ms / 2,000 ms | 
| コード長 | 1,137 bytes | 
| コンパイル時間 | 1,219 ms | 
| コンパイル使用メモリ | 104,492 KB | 
| 実行使用メモリ | 7,296 KB | 
| 最終ジャッジ日時 | 2024-12-26 14:03:41 | 
| 合計ジャッジ時間 | 2,605 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#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;
}
            
            
            
        