結果

問題 No.91 赤、緑、青の石
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-05 13:54:25
言語 Nim
(2.0.2)
結果
TLE  
実行時間 -
コード長 619 bytes
コンパイル時間 2,847 ms
コンパイル使用メモリ 67,880 KB
実行使用メモリ 11,480 KB
最終ジャッジ日時 2023-09-13 22:05:16
合計ジャッジ時間 15,186 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, math


proc nextString: string =
  result = ""
  while not endOfFile stdin:
    let nextChar = readChar stdin
    case nextChar
    of '\r':
      discard
    of "\n"[0], ' ':
      break
    else:
      add result, nextChar


proc nextInt: int =
  parseInt nextString()


let
  R, G, B = nextInt()
  S = [R, G, B].min

var
  L = [R, G, B].max
  M = [R, G, B].sum - S - L
  ans = 0


proc main: void =
  (ans, M, L) = (S, M - S, L - S)

  while L >= 3:
    let tmp = min(M, L div 3)
    ans += tmp
    M -= tmp
    L -= tmp * 3

    if L < M:
      swap(M, L)

  echo ans


when isMainModule:
  main()
0