結果

問題 No.2233 Average
ユーザー タコイモタコイモ
提出日時 2023-03-03 21:42:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 591 ms / 2,000 ms
コード長 2,695 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 81,252 KB
実行使用メモリ 78,656 KB
最終ジャッジ日時 2023-10-18 01:38:45
合計ジャッジ時間 6,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,272 KB
testcase_01 AC 44 ms
55,272 KB
testcase_02 AC 43 ms
55,272 KB
testcase_03 AC 44 ms
55,272 KB
testcase_04 AC 43 ms
55,272 KB
testcase_05 AC 44 ms
55,272 KB
testcase_06 AC 45 ms
55,272 KB
testcase_07 AC 50 ms
63,532 KB
testcase_08 AC 373 ms
77,364 KB
testcase_09 AC 529 ms
78,336 KB
testcase_10 AC 476 ms
77,324 KB
testcase_11 AC 462 ms
77,276 KB
testcase_12 AC 418 ms
77,084 KB
testcase_13 AC 144 ms
76,072 KB
testcase_14 AC 318 ms
77,176 KB
testcase_15 AC 415 ms
77,680 KB
testcase_16 AC 166 ms
76,276 KB
testcase_17 AC 191 ms
76,424 KB
testcase_18 AC 591 ms
78,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


import sys
#sys.setrecursionlimit(500000)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def TI(): return tuple(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip())
#for i, pi in enumerate(p):
from collections import defaultdict,deque
import bisect
import itertools
dic = defaultdict(int)
d = deque()
YN = ['No','Yes']

T = I()
for _ in range(T):
  a,b,c,K = MI()
  S = [a,b,c]
  S.sort()
  for i in range(K):
    a,b,c = S
    d = (b+c)//2
    e = (c+a)//2
    f = (a+b)//2
    SS = [d,e,f]
    SS.sort()
    
    if S == SS:
      break
    S = SS
  print(sum(SS))
0