結果
問題 | No.1701 half price |
ユーザー | harurun |
提出日時 | 2021-02-22 10:00:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,459 ms / 3,000 ms |
コード長 | 1,775 bytes |
コンパイル時間 | 1,251 ms |
コンパイル使用メモリ | 86,860 KB |
実行使用メモリ | 77,036 KB |
最終ジャッジ日時 | 2023-09-30 09:23:13 |
合計ジャッジ時間 | 7,413 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
71,316 KB |
testcase_01 | AC | 78 ms
76,056 KB |
testcase_02 | AC | 220 ms
76,784 KB |
testcase_03 | AC | 78 ms
75,832 KB |
testcase_04 | AC | 222 ms
76,912 KB |
testcase_05 | AC | 87 ms
76,076 KB |
testcase_06 | AC | 1,450 ms
76,948 KB |
testcase_07 | AC | 1,459 ms
77,036 KB |
testcase_08 | AC | 73 ms
71,196 KB |
testcase_09 | AC | 78 ms
76,092 KB |
testcase_10 | AC | 74 ms
71,200 KB |
testcase_11 | AC | 78 ms
75,988 KB |
testcase_12 | AC | 80 ms
76,108 KB |
testcase_13 | AC | 82 ms
76,096 KB |
testcase_14 | AC | 79 ms
76,112 KB |
testcase_15 | AC | 79 ms
75,984 KB |
testcase_16 | AC | 74 ms
71,452 KB |
testcase_17 | AC | 73 ms
71,492 KB |
testcase_18 | AC | 72 ms
71,488 KB |
testcase_19 | AC | 72 ms
71,332 KB |
testcase_20 | AC | 72 ms
71,384 KB |
testcase_21 | AC | 1,448 ms
76,772 KB |
ソースコード
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) if W==0 and A==[0]*N: print(pow(2,N)-1) return 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()