結果
問題 | No.2009 Drunkers' Contest |
ユーザー | ansain |
提出日時 | 2022-07-15 22:19:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 339 ms / 2,000 ms |
コード長 | 2,343 bytes |
コンパイル時間 | 1,342 ms |
コンパイル使用メモリ | 86,836 KB |
実行使用メモリ | 147,260 KB |
最終ジャッジ日時 | 2023-09-10 02:33:50 |
合計ジャッジ時間 | 15,857 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
71,940 KB |
testcase_01 | AC | 94 ms
71,728 KB |
testcase_02 | AC | 94 ms
71,840 KB |
testcase_03 | AC | 94 ms
71,716 KB |
testcase_04 | AC | 93 ms
71,956 KB |
testcase_05 | AC | 95 ms
71,760 KB |
testcase_06 | AC | 94 ms
71,760 KB |
testcase_07 | AC | 95 ms
71,792 KB |
testcase_08 | AC | 95 ms
71,640 KB |
testcase_09 | AC | 94 ms
72,040 KB |
testcase_10 | AC | 95 ms
71,764 KB |
testcase_11 | AC | 94 ms
72,076 KB |
testcase_12 | AC | 96 ms
72,044 KB |
testcase_13 | AC | 95 ms
72,012 KB |
testcase_14 | AC | 133 ms
78,896 KB |
testcase_15 | AC | 127 ms
78,276 KB |
testcase_16 | AC | 149 ms
79,320 KB |
testcase_17 | AC | 163 ms
78,916 KB |
testcase_18 | AC | 142 ms
79,312 KB |
testcase_19 | AC | 155 ms
78,816 KB |
testcase_20 | AC | 139 ms
78,664 KB |
testcase_21 | AC | 135 ms
78,732 KB |
testcase_22 | AC | 151 ms
78,728 KB |
testcase_23 | AC | 149 ms
78,768 KB |
testcase_24 | AC | 319 ms
145,272 KB |
testcase_25 | AC | 339 ms
145,244 KB |
testcase_26 | AC | 312 ms
145,252 KB |
testcase_27 | AC | 290 ms
145,248 KB |
testcase_28 | AC | 298 ms
145,420 KB |
testcase_29 | AC | 322 ms
145,284 KB |
testcase_30 | AC | 328 ms
145,076 KB |
testcase_31 | AC | 313 ms
145,236 KB |
testcase_32 | AC | 311 ms
145,404 KB |
testcase_33 | AC | 324 ms
145,436 KB |
testcase_34 | AC | 260 ms
146,968 KB |
testcase_35 | AC | 283 ms
147,220 KB |
testcase_36 | AC | 285 ms
147,136 KB |
testcase_37 | AC | 259 ms
147,012 KB |
testcase_38 | AC | 272 ms
147,072 KB |
testcase_39 | AC | 280 ms
147,192 KB |
testcase_40 | AC | 261 ms
147,028 KB |
testcase_41 | AC | 270 ms
147,176 KB |
testcase_42 | AC | 277 ms
147,260 KB |
testcase_43 | AC | 272 ms
147,032 KB |
testcase_44 | AC | 225 ms
146,536 KB |
testcase_45 | AC | 226 ms
146,940 KB |
testcase_46 | AC | 224 ms
142,436 KB |
testcase_47 | AC | 242 ms
145,340 KB |
testcase_48 | AC | 245 ms
145,492 KB |
testcase_49 | AC | 246 ms
134,692 KB |
testcase_50 | AC | 255 ms
134,612 KB |
testcase_51 | AC | 257 ms
144,924 KB |
testcase_52 | AC | 250 ms
137,248 KB |
testcase_53 | AC | 253 ms
142,400 KB |
testcase_54 | AC | 254 ms
142,528 KB |
testcase_55 | AC | 235 ms
141,164 KB |
testcase_56 | AC | 253 ms
141,324 KB |
testcase_57 | AC | 258 ms
141,672 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()