結果

問題 No.607 開通777年記念
ユーザー phsplsphspls
提出日時 2020-05-03 22:13:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 2,393 ms
コンパイル使用メモリ 164,812 KB
実行使用メモリ 4,364 KB
最終ジャッジ日時 2023-09-05 06:29:11
合計ジャッジ時間 4,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int main() {
    int n, m;
    cin >> n >> m;

    bool flg = false;
    vector<int> p(n, 0);
    rep(i, m) {
        rep(i, n) {
            int a;
            cin >> a;
            p[i] += a;
        }
        if(!flg) {
            int people = 0;
            int startidx = 0;
            rep(i, n) {
                while(people > 777) {
                    people -= p[startidx];
                    startidx++;
                }
                if(people == 777) {
                    flg = true;
                    break;
                }
                people += p[i];
            }
            while(people > 777) {
                people -= p[startidx];
                startidx++;
            }
            if(people == 777) {
                flg = true;
            }
        }
    }
    cout << (flg ? "YES" : "NO") << "\n";
}
0