結果

問題 No.1701 half price
ユーザー harurunharurun
提出日時 2021-02-22 09:49:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,718 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 76,736 KB
最終ジャッジ日時 2023-09-30 09:22:58
合計ジャッジ時間 7,931 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,548 KB
testcase_01 AC 79 ms
75,804 KB
testcase_02 AC 224 ms
76,568 KB
testcase_03 AC 77 ms
75,872 KB
testcase_04 AC 217 ms
76,436 KB
testcase_05 AC 85 ms
76,016 KB
testcase_06 AC 1,450 ms
76,432 KB
testcase_07 AC 1,445 ms
76,384 KB
testcase_08 WA -
testcase_09 AC 80 ms
75,796 KB
testcase_10 AC 73 ms
70,816 KB
testcase_11 AC 77 ms
75,872 KB
testcase_12 AC 78 ms
75,928 KB
testcase_13 AC 78 ms
75,416 KB
testcase_14 AC 79 ms
75,584 KB
testcase_15 AC 82 ms
75,700 KB
testcase_16 AC 75 ms
70,676 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 73 ms
70,756 KB
testcase_21 AC 1,439 ms
76,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class INPUT:
  def __init__(self):
    from sys import argv
    if argv[-1] in ["./Main.py","prog.py","Main.py"]:#Atcoder:./Main.py,Wandbox:prog.py,yukicoder:Main.py
      self.l=open(0).read().split()[::-1]
    else:
      self.l=open("_input.txt",mode="r").read().split()[::-1]
    self.length=len(self.l)
    return

  def stream(self,k=1,f=int,f2=False):
    assert(-1<k)
    m=self.length
    if m==0 or m<k:
      raise Exception("There is no input!")
    elif f!=str:
      if k==0:
        self.length=0
        return list(map(f,self.l[::-1]))
      if k==1 and not f2:
        self.length-=1
        return f(self.l.pop())
      if k==1 and f2:
        self.length-=1
        return [f(self.l.pop())]
      ret=[]
      for _ in [0]*k:
        ret.append(f(self.l.pop()))
      self.length-=k
      return ret
    else:
      if k==0:
        self.length=0
        return self.l[::-1]
      if k==1 and not f2:
        self.length-=1
        return self.l.pop()
      if k==1 and f2:
        self.length-=1
        return [self.l.pop()]
      ret=[]
      for _ in [0]*k:
        ret.append(self.l.pop())
      self.length-=k
      return ret
pin=INPUT().stream

def change(n,k):
  ret=""
  while n!=0:
    ret+=str(n%k)
    n//=k
  return ret

def main():
  N,W=pin(2)
  assert(1<=N<=13)
  assert(0<=W<=pow(10,9))
  A=pin(0)
  for i in A:
    assert(0<=i<=pow(10,9))
    debug=i%2
    assert(debug==0)
  ans=set()
  B=[i//2 for i in A]
  for i in range(3**N):
    s=0
    b=0
    x=1
    u=change(i,3)
    for j in range(len(u)):
      if u[j]=="1":
        s+=A[j]
        b+=x
      elif u[j]=="2":
        s+=B[j]
        b+=x
      x*=2
    if s==W:
      ans.add(b)
  print(len(ans))
  return

main()

0