結果
問題 |
No.3068 Speedrun (Hard)
|
ユーザー |
|
提出日時 | 2025-03-21 23:10:46 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,823 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 81,992 KB |
実行使用メモリ | 97,696 KB |
最終ジャッジ日時 | 2025-03-21 23:10:53 |
合計ジャッジ時間 | 6,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 4 TLE * 1 -- * 27 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) n = a.pop() t = b.pop() p,q,r,s = b #alist = [] #s = input() #n,m = map(int,input().split()) #for i in range(n): """ x + y + z + w = n px + qy + rz + sw = t (q-p)y + (r-p)z + (s-p)w = t - n*p """ for y in range(a[1]+1): for z in range(a[2]+1): if y+z > n or q*y + r*z > t:continue c = t - n*p - (q-p)*y - (r-p)*z d = (s-p) if c < 0 and d < 0: c *= -1 d *= -1 if c > 0 and d > 0: if c % d == 0: w = c//d x = n-y-z-w if 0 <= x <= a[0] and 0 <= w <= a[3]: assert x+y+z+w == n and p*x + q*y + r*z + s*w == t exit(print(n-y-z-w,y,z,w)) exit() # alist.append(list(map(int,input().split()))) se = set() m = 40001 for i in range(a[0]+1): for j in range(a[1]+1): cnt = i+j ti = i * b[0] + j * b[1] if ti > t: continue se.add(ti * m + cnt) cnt3,ti3 = 0,0 a1,a2 = 0,0 for i in range(a[2]+1): for j in range(a[3]+1): cnt = i+j ti = i * b[2] + j * b[3] if ti > t: continue cnt2 = n - cnt ti2 = t - ti if cnt2 < 0: continue if ti2 < 0: continue if ti2 * m + cnt2 in se: ti3 = ti cnt3 = cnt a1,a2 = i,j break for i in range(a[0]+1): for j in range(a[1]+1): cnt = i+j ti = i * b[0] + j * b[1] if cnt + cnt3 == n and ti + ti3 == t: exit(print(i,j,a1,a2))