結果

問題 No.647 明太子
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-06-15 21:18:17
言語 Nim
(2.0.2)
結果
AC  
実行時間 72 ms / 4,500 ms
コード長 668 bytes
コンパイル時間 3,475 ms
コンパイル使用メモリ 68,936 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 04:44:10
合計ジャッジ時間 5,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 55 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 67 ms
4,376 KB
testcase_18 AC 72 ms
4,376 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 17 ms
4,380 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 67 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, algorithm
proc getInts: auto = stdin.readLine.split.map parseInt

let N = stdin.readLine.parseInt
var person = newSeq[tuple[cost, taste: int]](N)

for i in 0 ..< N:
  (person[i].cost, person[i].taste) = getInts()

let M = stdin.readLine.parseInt
var mentai = newSeq[tuple[cost, taste, pop: int]](M)

for j in 0 ..< M:
  (mentai[j].cost, mentai[j].taste) = getInts()
  for i in 0 ..< N:
    if mentai[j].cost <= person[i].cost:
      if mentai[j].taste >= person[i].taste:
        mentai[j].pop += 1

let best = sortedByIt(mentai, -it.pop)[0].pop
if best > 0:
  for j in 0 ..< M:
    if mentai[j].pop == best:
      echo j + 1
else:
  echo 0
0