ABC078 C - HSI

備忘録

問題

atcoder.jp

回答

import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    o = 1900 * M + (N - M) * 100
    print(o * (2 ** M))


if __name__ == '__main__':
    main()

考え方

1回の提出にかかる時間を求めて、
正解までに必要な試行回数で乗算することで回答。


1回の提出に必要な時間は、
Mケースは1回1900ms、(N-M)ケースでは100msのため、
1回の提出に必要な時間(ms) = M * 1900 + (N - M) * 100となる。

正解に必要な試行回数は、各M個のケースが、
それぞれ1 / 2で正解することが出来ることから、
全て正解するためには2 ** M回の試行が必要となる。

あとは1回の提出に必要な時間 * 全て正解するために必要な試行回数で回答を得ることが出来る。