結果

問題 No.1708 Quality of Contest
ユーザー kasuyaSansankasuyaSansan
提出日時 2021-10-26 13:15:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,322 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 268,040 KB
最終ジャッジ日時 2024-04-15 11:51:57
合計ジャッジ時間 9,403 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,952 KB
testcase_01 AC 41 ms
52,544 KB
testcase_02 AC 42 ms
52,488 KB
testcase_03 AC 949 ms
82,544 KB
testcase_04 AC 1,221 ms
85,476 KB
testcase_05 AC 1,038 ms
81,236 KB
testcase_06 AC 665 ms
80,108 KB
testcase_07 AC 680 ms
80,196 KB
testcase_08 AC 42 ms
52,704 KB
testcase_09 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,X = map(int, input().split(" "))

questions = []
for i in range(N):
    questions.append(list(map(int, input().split(" "))))

K = int(input())
num_answers = list(map(int, input().split(" ")))


def calc_confident(question_list, num_answers, X):
    sum = 0
    for num in num_answers:
        janru = set()
        for i in range(num):
            janru.add(question_list[i][1])
            sum += question_list[i][0]
        sum += len(janru)*X
    return sum


def get_max(sorted_list, now_list, N, X):
    #sorted_list = sorted(questions, key= lambda x:-x[0])
    if not now_list:
        return sorted_list[0]

    j_set = set([j[1] for j in now_list])
    n_j = len(j_set)
    if n_j == N:
        return sorted_list[0]

    max_q = sorted_list[0]
    other_j_list = [s for s in sorted_list if s[1] not in j_set]
    if not other_j_list:
        return max_q
    max_q_j = other_j_list[0]

    if max_q == max_q_j:
        return max_q

    dif = max_q[0] - max_q_j[0]
    if dif > X:
        return max_q
    else:
        return max_q_j

questions = sorted_list = sorted(questions, key= lambda x:-x[0])
now_list = []
for i in range(len(questions)):
    max_q =get_max(questions, now_list, N,X)

    now_list.append(max_q)
    questions.remove(max_q)



val = calc_confident(now_list, num_answers, X)
print(val)
0