結果

問題 No.607 開通777年記念
ユーザー treeonetreeone
提出日時 2017-12-10 01:48:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 161,400 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 13:11:39
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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