結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー むらため
提出日時 2019-01-20 09:27:47
言語 Nim
(2.2.0)
結果
AC  
実行時間 763 ms / 5,000 ms
コード長 743 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,846 ms
コンパイル使用メモリ 68,132 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-07 12:33:07
合計ジャッジ時間 11,503 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #
raw source code

import sequtils,algorithm,math
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)

var rgb = @[scan(),scan(),scan()]
var ans = 0
while true:
  rgb = rgb.filterIt(it > 0)
  if rgb.len == 0 : break
  # echo rgb,ans
  let x = rgb.max()
  let y = rgb.min()
  if rgb.len == 3: # 3つ
    rgb = rgb.mapIt(it - y)
    ans += y
  elif rgb.len == 2:
    if x <= 2 : break
    ans += 1
    rgb = @[y-1,x-3]
  elif rgb.len == 1:
    ans += x div 5
    break
echo ans
0