結果

問題 No.437 cwwゲーム
ユーザー t8m8⛄️
提出日時 2016-10-30 17:24:04
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 636 bytes
コンパイル時間 2,953 ms
コンパイル使用メモリ 66,996 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 19:47:11
合計ジャッジ時間 3,754 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import strutils, sequtils

var
  s = stdin.readline
  used : seq[bool]
  cnt : seq[int]
  ans = 0

if len(s) < 3:
  echo(0)
  quit()

var n = len(s)
used.newSeq(n)
cnt.newSeq(10)

for i in countdown(n-1, 0):
  if used[i]: continue
  var m = ord(s[i]) - ord('0')
  cnt[m] += 1
  if cnt[m] == 2:
    var
      idx = -1
      max = -1

    for j in countdown(i-1, 0):
      if not used[j] and max < ord(s[j]) and s[j] != s[i] and s[j] != '0':
        idx = j
        max = ord(s[j])

    if idx == -1: break

    cnt[m] -= 2
    used[idx] = true
    # echo parseint(s[idx] & s[i] & s[i])
    ans += parseint(s[idx] & s[i] & s[i])

ans.echo
0