結果

問題 No.607 開通777年記念
コンテスト
ユーザー yuppe19 😺
提出日時 2017-12-07 16:23:11
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 51 ms / 2,000 ms
+ 691µs
コード長 613 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 968 ms
コンパイル使用メモリ 168,024 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2026-07-28 01:49:40
合計ジャッジ時間 2,296 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   int n, m; scanf("%d%d", &n, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~
main.cpp:12:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |       scanf("%d", &a[i][j]);
      |       ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
using namespace std;
using i64 = long long;

int main(void) {
  int n, m; scanf("%d%d", &n, &m);
  vector<vector<int>> a(m, vector<int>(n, 0)); // a[m][n]
  vector<int> b(n, 0); // b[i] := [0, i) の乗車人数
  for(int i=0; i<m; ++i) {
    for(int j=0; j<n; ++j) {
      scanf("%d", &a[i][j]);
      b[j] += a[i][j];
    }
    int acc = 0;
    for(int l=0, r=0; r<n; ++r) {
      acc += b[r];
      while(acc > 777)  {
        acc -= b[l];
        ++l;
      }
      if(acc == 777) {
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");
  return 0;
}
0