結果

問題 No.607 開通777年記念
ユーザー otoshigootoshigo
提出日時 2024-01-27 18:57:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 79,840 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-27 18:57:39
合計ジャッジ時間 2,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin>>N>>M;
    vector<int>A(N);
    bool ok=false;
    while(M--){
        for(int i=0;i<N;i++){
            int d;
            cin>>d;
            A[i]+=d;
        }
        if(ok)continue;
        vector<int>S(N+1);
        for(int i=0;i<N;i++)S[i+1]=S[i]+A[i];
        for(int i=0;i<N;i++){
            if(S[i]+777>S.back())break;
            if(*lower_bound(all(S),S[i]+777)==S[i]+777){
                ok=true;
            }
        }
    }
    cout<<(ok?"YES":"NO")<<"\n";
}
0