結果

問題 No.607 開通777年記念
ユーザー 0w1
提出日時 2017-12-14 12:56:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 197,312 KB
最終ジャッジ日時 2025-01-05 05:21:27
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1 << 10;
const int MAXM = 1 << 10;

int N, M;
int A[MAXM][MAXN];
int cur[MAXN];
int pcur[MAXN + 1];

signed main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      cur[j] += A[i][j];
    }
    for (int j = 0; j < N; ++j) {
      pcur[j + 1] = pcur[j] + cur[j];
    }
    multiset<int> bag;
    for (int j = 0; j <= N; ++j) {
      bag.emplace(pcur[j]);
    }
    for (int j = 0; j < N; ++j) {
      bag.erase(bag.find(pcur[j]));
      if (bag.count(777 + pcur[j])) {
        cout << "YES" << endl;
        exit(0);
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
0