結果

問題 No.607 開通777年記念
ユーザー te-shte-sh
提出日時 2017-12-07 10:22:39
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 89,680 KB
実行使用メモリ 6,712 KB
最終ジャッジ日時 2023-09-03 17:17:23
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1];
  auto a = new int[](n), b = new int[](n);
  foreach (i; 0..m) {
    auto rd2 = readln.splitter;
    foreach (j; 0..n) {
      a[j] = rd2.front.to!int;
      rd2.popFront();
    }
    foreach (j; 1..n) a[j] += a[j-1];
    b[] += a[];

    auto bs = b.assumeSorted!"a < b";
    if (bs.contains(777)) {
      writeln("YES");
      return;
    }
    foreach (bi; bs.upperBound(777)) {
      if (bs.contains(bi-777)) {
        writeln("YES");
        return;
      }
    }
  }
  writeln("NO");
}
0