結果

問題 No.1389 Clumsy Calculation
ユーザー ansainansain
提出日時 2021-02-12 21:54:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 2,529 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 33,356 KB
最終ジャッジ日時 2023-09-27 03:48:03
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,776 KB
testcase_01 AC 21 ms
8,800 KB
testcase_02 AC 20 ms
8,948 KB
testcase_03 AC 22 ms
9,112 KB
testcase_04 AC 24 ms
9,192 KB
testcase_05 AC 24 ms
9,212 KB
testcase_06 AC 21 ms
9,188 KB
testcase_07 AC 21 ms
9,164 KB
testcase_08 AC 20 ms
8,772 KB
testcase_09 AC 91 ms
31,404 KB
testcase_10 AC 62 ms
12,348 KB
testcase_11 AC 22 ms
9,016 KB
testcase_12 AC 22 ms
9,016 KB
testcase_13 AC 22 ms
9,132 KB
testcase_14 AC 95 ms
30,632 KB
testcase_15 AC 96 ms
30,568 KB
testcase_16 AC 96 ms
30,628 KB
testcase_17 AC 94 ms
30,908 KB
testcase_18 AC 94 ms
30,848 KB
testcase_19 AC 93 ms
30,880 KB
testcase_20 AC 94 ms
30,952 KB
testcase_21 AC 96 ms
31,020 KB
testcase_22 AC 95 ms
30,852 KB
testcase_23 AC 95 ms
30,960 KB
testcase_24 AC 94 ms
30,880 KB
testcase_25 AC 94 ms
30,828 KB
testcase_26 AC 94 ms
33,356 KB
testcase_27 AC 95 ms
30,628 KB
testcase_28 AC 94 ms
30,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict, Counter, deque
from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate
import operator
from math import sqrt, gcd, factorial
# from math import isqrt, prod,comb  # python3.8用(notpypy)
#from bisect import bisect_left,bisect_right
#from functools import lru_cache,reduce
#from heapq import heappush,heappop,heapify,heappushpop,heapreplace
#import numpy as np
#import networkx as nx
#from networkx.utils import UnionFind
#from numba import njit, b1, i1, i4, i8, f8
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, NegativeCycleError
# numba例 @njit(i1(i4[:], i8[:, :]),cache=True) 引数i4配列、i8 2次元配列,戻り値i1
def input(): return sys.stdin.readline().rstrip()
def divceil(n, k): return 1+(n-1)//k  # n/kの切り上げを返す
def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no)


#https://note.nkmk.me/python-union-find/から一部改変
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        self.all_group_member=defaultdict(list)
        for i in range(self.n):
            self.all_group_member[self.find(i)].append(i)
        return self.all_group_member

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    mod = 10**9+7
    mod2 = 998244353
    n,x=map(int, input().split())
    S=list(map(int, input().split()))
    A=sum(x-ss for ss in S)
    print(x-A)



if __name__ == '__main__':
    main()
0