結果

問題 No.607 開通777年記念
ユーザー ミドリムシミドリムシ
提出日時 2017-12-07 06:37:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 68,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 18:22:58
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
    int N, M;
    cin >> N >> M;
    int vehicles[N];
    fill(vehicles, vehicles + N, 0);
    for(int i = 0; i < M; i++){
        for(int j = 0; j < N; j++){
            int plus;
            cin >> plus;
            vehicles[j] += plus;
        }
        int left = 0;
        int right = 0;
        int sum = 0;
        while(right < N){
            if(sum < 777){
                sum += vehicles[right];
                right++;
            }else if(sum > 777){
                sum -= vehicles[left];
                left++;
            }
            if(sum == 777){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}
0