結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー むらためむらため
提出日時 2017-08-15 20:23:11
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 741 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 72,080 KB
最終ジャッジ日時 2024-04-27 02:29:06
合計ジャッジ時間 1,251 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(13, 6) Error: type mismatch
Expression: c_fgets(buf, 200002, stdin)
  [1] buf: array[0..200001, char]
  [2] 200002: int
  [3] stdin: File

Expected one of (first mismatch at [position]):
[1] proc c_fgets(c`gensym1: cstring; n`gensym1: int; file`gensym1: File): void

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,future,macros
import sets,tables,hashes
template get*():string = stdin.readLine() #.strip()
proc enumerate[T](arr:seq[T]): seq[tuple[i:int,val:T]] =
  result = @[]; for i,a in arr: result &= (i,a)

template fgets(buf:untyped,size:int,f:File):void =
  proc c_fgets(c: cstring, n: int, file: File): void {.importc: "fgets", header: "<stdio.h>", tags: [ReadIOEffect].}
  var buf: array[size, char]
  c_fgets(buf,sizeof((buf)),f)

let N = get().parseInt
fgets(buf,100000 * 2 + 2,stdin)
var ans = newSeqWith(7,0)
for b in buf:
  if b < '0' or b > '9' : continue
  ans[b.ord - '0'.ord] += 1
echo ans.enumerate()
  .sorted((x,y) => (if x[1] != y[1] : x[1] - y[1] else: x[0] - y[0]),Descending)[0].i
0