結果

問題 No.709 優勝可能性
ユーザー ikdikd
提出日時 2018-07-15 15:22:59
言語 Nim
(2.0.2)
結果
AC  
実行時間 392 ms / 3,500 ms
コード長 615 bytes
コンパイル時間 5,534 ms
コンパイル使用メモリ 69,952 KB
実行使用メモリ 16,912 KB
最終ジャッジ日時 2023-09-13 18:32:44
合計ジャッジ時間 9,503 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 226 ms
4,376 KB
testcase_11 AC 182 ms
4,380 KB
testcase_12 AC 300 ms
4,376 KB
testcase_13 AC 327 ms
4,380 KB
testcase_14 AC 309 ms
4,380 KB
testcase_15 AC 299 ms
4,380 KB
testcase_16 AC 303 ms
5,528 KB
testcase_17 AC 319 ms
16,912 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 392 ms
4,380 KB
testcase_21 AC 389 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils
var 
  args=stdin.readLine.split.map(parseInt)
  (n, m)=(args[0], args[1])

var
  deg=newSeq[int](n)
  stack=newSeqWith(m, newSeq[int]())
  top=newSeq[int](m)
  cnt=0

for i in 0..<n:
  var
    params=stdin.readLine.split.map(parseInt)
    ad=false
  for j, val in params:
    if top[j]<val:
      while stack[j].len>0:
        var k=stack[j].pop
        deg[k]-=1
        if deg[k]==0:
          cnt-=1
      stack[j].add(i)
      deg[i]+=1
      top[j]=val
      ad=true
    elif top[j]==val:
      stack[j].add(i)
      deg[i]+=1
      ad=true
    # else:
  if ad:
    cnt+=1
  echo cnt
0