結果

問題 No.91 赤、緑、青の石
ユーザー むらためむらため
提出日時 2019-01-20 08:32:04
言語 Nim
(2.0.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 70,220 KB
実行使用メモリ 7,204 KB
最終ジャッジ日時 2023-09-14 02:21:55
合計ジャッジ時間 9,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 27) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

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()]
rgb = rgb.filterIt(it > 0)
var ans = 0
while true:
  rgb = rgb.filterIt(it > 0)
  # echo rgb,ans
  if rgb.len == 3: # 5 18 36
    var del = rgb.min()
    rgb = rgb.mapIt(it - del)
    ans += del
  elif rgb.len == 2: # 0 13 31
    let x = rgb.max()
    let y = rgb.min()
    var n = (x - y) div 2
    if n > 1 and n >= x - n * 2: n = n div 2
    if n == 0 :
      if x == 2: break
      rgb = @[x mod 4,y mod 4]
      ans += y div 4 * 2
    else:
      rgb = @[x - n * 2, y , n ] # 9 13 13
  elif rgb.len == 1:
    let r = rgb[0]
    if r <= 4: break
    rgb = @[1,1,r - 4]
  else: break
echo ans
0