結果

問題 No.607 開通777年記念
ユーザー treeonetreeone
提出日時 2017-12-10 01:48:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 2,744 ms
コンパイル使用メモリ 146,420 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 05:49:31
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 15 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 80 ms
4,376 KB
testcase_12 AC 74 ms
4,376 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