結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
|
提出日時 | 2019-01-20 08:44:36 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,145 bytes |
コンパイル時間 | 2,521 ms |
コンパイル使用メモリ | 62,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 10:25:11 |
合計ジャッジ時間 | 3,473 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 3 |
コンパイルメッセージ
/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]
ソースコード
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 == 3: rgb = @[1,y,1] continue if x <= 2: break if x == 4 and y == 3: rgb = @[1,2,3] continue rgb = @[x - (y div 4) * 4,y - (y div 4) * 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