結果

問題 No.607 開通777年記念
ユーザー Ryu
提出日時 2018-01-03 23:43:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 71,580 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 02:32:43
合計ジャッジ時間 1,817 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> vec(N, 0);
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < N; j++)
        {
            int x;
            cin >> x;
            vec[j] += x;
        }

        int left = 0, right = 0, sum = vec[0];
        while (true)
        {
            if (sum < 777)
            {
                right++;
                if (right == N)
                    break;
                sum += vec[right];
            }
            else if (sum > 777)
            {
                sum -= vec[left];
                left++;
                if (left == N)
                    break;
            }
            else if (sum == 777)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}
0