結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー 6soukiti296soukiti29
提出日時 2017-09-14 10:02:47
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 71,936 KB
実行使用メモリ 24,284 KB
最終ジャッジ日時 2023-09-12 15:10:35
合計ジャッジ時間 8,010 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
24,256 KB
testcase_01 AC 154 ms
24,072 KB
testcase_02 AC 19 ms
4,380 KB
testcase_03 AC 18 ms
4,376 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 19 ms
4,384 KB
testcase_07 AC 19 ms
4,376 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 149 ms
21,856 KB
testcase_13 AC 158 ms
23,856 KB
testcase_14 AC 154 ms
21,688 KB
testcase_15 AC 155 ms
21,840 KB
testcase_16 AC 147 ms
21,244 KB
testcase_17 AC 144 ms
21,252 KB
testcase_18 AC 149 ms
21,200 KB
testcase_19 AC 154 ms
21,772 KB
testcase_20 AC 147 ms
21,604 KB
testcase_21 AC 150 ms
21,188 KB
testcase_22 WA -
testcase_23 AC 19 ms
4,376 KB
testcase_24 AC 14 ms
4,376 KB
testcase_25 AC 14 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm,math

type
    item = tuple[x, a, b, id : int]

var
    N, M : int
    x, a, b : int
    A = newSeq[item](0)
    flag : array[100001,int]
    cnt : array[6, int]
(N, M) = stdin.readline.split.map(parseInt)
for n in 0..<N:
    (x, a, b) = stdin.readline.split.map(parseInt)
    A.add((x,a,b,n))
    flag[n] = x + 1
    cnt[x + 1] += 1
var
    B = A.sortedByIt(it.b)
A = A.sortedByIt(it.a)
var
    i = 0
    j = 100001
    pai,paj,pbi,pbj : int
pbj = B.high
paj = B.high
var ans = int.high
while j > -1 or i < 100001:
    if sum(cnt[2..5]) < M and j > 0:
        j -= 1
        while pbj >= 0 and B[pbj].b >= j:
            var f = B[pbj].id
            cnt[flag[f]] -= 1
            cnt[flag[f] + 1] += 1
            flag[f] += 1
            pbj -= 1
    elif sum(cnt[2..5]) >= M and i < 100000:
        ans = min(ans, sum(cnt[3..5]))
        i += 1
        while pai < A.len and A[pai].a <= i:
            var f = A[pai].id
            cnt[flag[f]] -= 1
            cnt[flag[f] - 1] += 1
            flag[f] -= 1
            pai += 1
    else:
        break
echo ans
0