結果
| 問題 | No.607 開通777年記念 | 
| コンテスト | |
| ユーザー |  treeone | 
| 提出日時 | 2017-12-10 01:48:33 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 71 ms / 2,000 ms | 
| コード長 | 983 bytes | 
| コンパイル時間 | 2,426 ms | 
| コンパイル使用メモリ | 161,404 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-30 06:08:09 | 
| 合計ジャッジ時間 | 2,048 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
int n, m;
vector<int> a;
bool calc(){
    bool res = (a[0] == 777);
    int r = 1, sum = a[0];
    rep(l, 0, n){
        while(r < n && sum + a[r] <= 777){
            sum += a[r];
            r++;
        }
        res |= (sum == 777);
        sum -= a[l];
    }
    return res;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    a.resize(n);
    bool ans = false;
    rep(i, 0, m){
        rep(j, 0, n){
            int in; cin >> in;
            a[j] += in;
        }
        ans |= calc();
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}
            
            
            
        