結果
問題 | No.2008 Super Worker |
ユーザー | Kazun |
提出日時 | 2022-04-27 01:24:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,348 ms / 2,000 ms |
コード長 | 5,141 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 133,284 KB |
最終ジャッジ日時 | 2024-06-28 07:34:12 |
合計ジャッジ時間 | 17,729 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
53,632 KB |
testcase_01 | AC | 45 ms
52,992 KB |
testcase_02 | AC | 42 ms
53,504 KB |
testcase_03 | AC | 42 ms
53,376 KB |
testcase_04 | AC | 43 ms
53,248 KB |
testcase_05 | AC | 43 ms
53,504 KB |
testcase_06 | AC | 44 ms
53,504 KB |
testcase_07 | AC | 43 ms
53,120 KB |
testcase_08 | AC | 44 ms
53,760 KB |
testcase_09 | AC | 43 ms
53,376 KB |
testcase_10 | AC | 44 ms
53,504 KB |
testcase_11 | AC | 43 ms
53,632 KB |
testcase_12 | AC | 44 ms
53,376 KB |
testcase_13 | AC | 70 ms
69,760 KB |
testcase_14 | AC | 73 ms
72,832 KB |
testcase_15 | AC | 70 ms
70,784 KB |
testcase_16 | AC | 71 ms
71,552 KB |
testcase_17 | AC | 71 ms
71,936 KB |
testcase_18 | AC | 78 ms
76,544 KB |
testcase_19 | AC | 63 ms
66,560 KB |
testcase_20 | AC | 68 ms
70,400 KB |
testcase_21 | AC | 67 ms
70,400 KB |
testcase_22 | AC | 61 ms
66,944 KB |
testcase_23 | AC | 1,278 ms
132,656 KB |
testcase_24 | AC | 1,348 ms
131,872 KB |
testcase_25 | AC | 1,288 ms
132,804 KB |
testcase_26 | AC | 1,296 ms
133,284 KB |
testcase_27 | AC | 1,308 ms
132,900 KB |
testcase_28 | AC | 1,307 ms
124,392 KB |
testcase_29 | AC | 1,279 ms
124,536 KB |
testcase_30 | AC | 1,306 ms
124,400 KB |
testcase_31 | AC | 1,286 ms
124,388 KB |
testcase_32 | AC | 1,307 ms
124,132 KB |
testcase_33 | AC | 236 ms
125,852 KB |
testcase_34 | AC | 1,311 ms
125,276 KB |
testcase_35 | AC | 234 ms
131,064 KB |
ソースコード
from math import gcd class Fraction(): reduction=0 __slots__=("a","b") ##入力定義 def __init__(self, Numerator=0, Denominator=1, reduction=True, expanded=False): """分数のオブジェクトを生成する. Numerator: 分子 Denominator: 分母 (!=0) """ assert Denominator or expanded,"分母が0" if Denominator<0: Numerator*=-1 Denominator*=-1 self.a=Numerator self.b=Denominator if reduction: g=gcd(Numerator, Denominator) self.a=Numerator//g self.b=Denominator//g #表示定義 def __str__(self): if self.b==1: return str(self.a) else: return "{}/{}".format(self.a,self.b) __repr__=__str__ #四則演算定義 def __add__(self,other): if other.__class__==Fraction: x=self.a*other.b+self.b*other.a y=self.b*other.b elif other.__class__==int: x=self.a+self.b*other y=self.b else: assert 0,"型が違う" return Fraction(x,y) def __radd__(self,other): return self+other def __sub__(self,other): if other.__class__==Fraction: x=self.a*other.b-self.b*other.a y=self.b*other.b elif other.__class__==int: x=self.a-self.b*other y=self.b else: assert 0,"型が違う" return Fraction(x,y) def __rsub__(self,other): return -self+other def __mul__(self,other): if other.__class__==Fraction: x=self.a*other.a y=self.b*other.b elif other.__class__==int: x=self.a*other y=self.b else: assert 0,"型が違う" return Fraction(x,y) def __rmul__(self,other): return self*other def __floordiv__(self,other): if other==Fraction(): raise ZeroDivisionError H=self/other return H.a//H.b def __rfloordiv__(self,other): if self==Fraction(): raise ZeroDivisionError H=other/self return H.a//H.b def __truediv__(self,other): assert other,"除数が0" if other.__class__==Fraction: x=self.a*other.b y=self.b*other.a elif other.__class__==int: x=self.a y=self.b*other else: assert 0,"型が違う" return Fraction(x,y) def __rtruediv__(self,other): assert self,"除数が0" if other.__class__==Fraction: x=other.a*self.b y=other.b*self.a elif other.__class__==int: x=other*self.b y=self.a else: assert 0,"型が違う" return Fraction(x,y) def __pow__(self,m): alpha,beta=self.a,self.b if m<0: alpha,beta=beta,alpha m=-m return Fraction(pow(alpha,m),pow(beta,m)) #丸め def __floor__(self): return self.a//self.b def __ceil__(self): return (self.a+self.b-1)//self.b #真偽値 def __bool__(self): return bool(self.a) #比較 def __eq__(self,other): if other.__class__==Fraction: return self.a*other.b==self.b*other.a elif other.__class__==int: return self.a==self.b*other else: assert 0,"型が違う" def __nq__(self,other): return not(self==other) def __lt__(self,other): return self<=other and self!=other def __le__(self,other): if other.__class__==Fraction: return self.a*other.b<=self.b*other.a elif other.__class__==int: return self.a<=self.b*other else: assert 0,"型が違う" def __gt__(self,other): return other<=self and other!=self def __ge__(self,other): return other<=self #その他 def __float__(self): return self.a/self.b def sign(self): s=self.a*self.b if s>0:return 1 elif s==0:return 0 else:return -1 #符号 def __pos__(self): return self def __neg__(self): return Fraction(-self.a,self.b) def __abs__(self): if self.a>0: return self else: return -self #その他 def is_unit(self): return self.a==1 def __hash__(self): return hash(10**9*self.a+self.b) #================================================== from operator import itemgetter N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) W=[(i,Fraction(b-1,a,False)) for i,(a,b) in enumerate(zip(A,B))] W.sort(key=itemgetter(1),reverse=True) Ans=0; Mod=10**9+7 Level=1; for i,_ in W: Ans+=A[i]*Level; Ans%=Mod Level*=B[i]; Level%=Mod print(Ans)