結果
問題 | No.2009 Drunkers' Contest |
ユーザー | ansain |
提出日時 | 2022-07-15 22:19:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 293 ms / 2,000 ms |
コード長 | 2,343 bytes |
コンパイル時間 | 893 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 160,012 KB |
最終ジャッジ日時 | 2024-06-27 18:43:16 |
合計ジャッジ時間 | 13,128 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
54,144 KB |
testcase_01 | AC | 45 ms
53,888 KB |
testcase_02 | AC | 46 ms
54,016 KB |
testcase_03 | AC | 46 ms
53,760 KB |
testcase_04 | AC | 46 ms
54,016 KB |
testcase_05 | AC | 46 ms
54,272 KB |
testcase_06 | AC | 46 ms
53,888 KB |
testcase_07 | AC | 46 ms
54,400 KB |
testcase_08 | AC | 46 ms
53,888 KB |
testcase_09 | AC | 45 ms
53,888 KB |
testcase_10 | AC | 46 ms
53,888 KB |
testcase_11 | AC | 46 ms
54,144 KB |
testcase_12 | AC | 46 ms
53,888 KB |
testcase_13 | AC | 47 ms
54,528 KB |
testcase_14 | AC | 98 ms
76,672 KB |
testcase_15 | AC | 94 ms
76,800 KB |
testcase_16 | AC | 114 ms
77,000 KB |
testcase_17 | AC | 126 ms
77,792 KB |
testcase_18 | AC | 104 ms
77,440 KB |
testcase_19 | AC | 118 ms
77,824 KB |
testcase_20 | AC | 103 ms
77,440 KB |
testcase_21 | AC | 99 ms
76,672 KB |
testcase_22 | AC | 115 ms
77,720 KB |
testcase_23 | AC | 110 ms
77,440 KB |
testcase_24 | AC | 279 ms
144,344 KB |
testcase_25 | AC | 289 ms
146,644 KB |
testcase_26 | AC | 272 ms
144,856 KB |
testcase_27 | AC | 255 ms
144,332 KB |
testcase_28 | AC | 257 ms
144,600 KB |
testcase_29 | AC | 288 ms
144,852 KB |
testcase_30 | AC | 293 ms
144,988 KB |
testcase_31 | AC | 276 ms
144,848 KB |
testcase_32 | AC | 278 ms
144,976 KB |
testcase_33 | AC | 289 ms
144,468 KB |
testcase_34 | AC | 239 ms
154,700 KB |
testcase_35 | AC | 243 ms
154,952 KB |
testcase_36 | AC | 252 ms
155,104 KB |
testcase_37 | AC | 229 ms
155,092 KB |
testcase_38 | AC | 240 ms
155,480 KB |
testcase_39 | AC | 244 ms
154,960 KB |
testcase_40 | AC | 232 ms
155,348 KB |
testcase_41 | AC | 238 ms
155,308 KB |
testcase_42 | AC | 248 ms
155,548 KB |
testcase_43 | AC | 240 ms
155,352 KB |
testcase_44 | AC | 192 ms
142,104 KB |
testcase_45 | AC | 188 ms
142,220 KB |
testcase_46 | AC | 200 ms
159,976 KB |
testcase_47 | AC | 194 ms
137,000 KB |
testcase_48 | AC | 195 ms
137,392 KB |
testcase_49 | AC | 205 ms
137,520 KB |
testcase_50 | AC | 224 ms
137,264 KB |
testcase_51 | AC | 217 ms
137,136 KB |
testcase_52 | AC | 215 ms
137,260 KB |
testcase_53 | AC | 225 ms
160,012 KB |
testcase_54 | AC | 227 ms
157,776 KB |
testcase_55 | AC | 213 ms
158,296 KB |
testcase_56 | AC | 227 ms
158,436 KB |
testcase_57 | AC | 228 ms
158,416 KB |
ソースコード
import sys from collections import defaultdict, Counter, deque from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate import operator from math import sqrt, gcd, factorial #from math import isqrt, prod, comb #python3.8用(notpypy) #from bisect import bisect_left, bisect_right #from functools import lru_cache, reduce #from heapq import heappush, heappop, heapify, heappushpop, heapreplace #import numpy as np #import networkx as nx #from networkx.utils import UnionFind #from numba import njit, b1, i1, i4, i8, f8 #numba例 @njit(i1(i4[:], i8[:, :]),cache=True) 引数i4配列、i8 2次元配列,戻り値i1 #from scipy.sparse import csr_matrix #from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, NegativeCycleError, maximum_bipartite_matching, maximum_flow, minimum_spanning_tree def input(): return sys.stdin.readline().rstrip() def divceil(n, k): return 1+(n-1)//k # n/kの切り上げを返す def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no) def check(AA,BB): if AA <= BB: return 1,AA+BB else: return sqrt(AA/BB),BB*sqrt(AA/BB)*2 def check2(drink,AA,BB): r=max(drink,sqrt(AA/BB)) return r,AA/r+BB*r def main(): mod = 10**9+7 mod2 = 998244353 n=int(input()) A=list(map(int, input().split())) B=list(map(int, input().split())) accA=[0]+list(accumulate(A)) accB=[0]+list(accumulate(B)) t,y=check(A[0],B[0]) stack=[[-1,1,0],[0,t,y]] for i in range(1,n): while len(stack) > 1: index1,drink1,time1=stack[-1] index2,drink2,time2=stack[-2] if check2(drink1,accA[i+1]-accA[index1+1],accB[i+1]-accB[index1+1])[1] + time1 >= check2(drink2,accA[i+1]-accA[index2+1],accB[i+1]-accB[index2+1])[1] + time2: stack.pop() else: d,t=check2(drink1,accA[i+1]-accA[index1+1],accB[i+1]-accB[index1+1]) if d>drink1 or i==n-1: stack.append([i,d,time1+t]) break if len(stack)==1: index1,drink1,time1=stack[-1] d,t=check2(drink1,accA[i+1]-accA[index1+1],accB[i+1]-accB[index1+1]) stack.append([i,d,time1+t]) print(stack[-1][2]) if __name__ == '__main__': main()