結果
問題 | No.2594 Mix shake!! |
ユーザー | 👑 rin204 |
提出日時 | 2023-12-26 23:09:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 342 ms / 2,000 ms |
コード長 | 2,487 bytes |
コンパイル時間 | 569 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 90,044 KB |
最終ジャッジ日時 | 2024-09-27 15:18:10 |
合計ジャッジ時間 | 19,507 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
88,320 KB |
testcase_01 | AC | 129 ms
88,448 KB |
testcase_02 | AC | 135 ms
88,576 KB |
testcase_03 | AC | 135 ms
88,296 KB |
testcase_04 | AC | 132 ms
88,168 KB |
testcase_05 | AC | 131 ms
88,564 KB |
testcase_06 | AC | 133 ms
88,704 KB |
testcase_07 | AC | 133 ms
88,576 KB |
testcase_08 | AC | 138 ms
88,440 KB |
testcase_09 | AC | 133 ms
88,168 KB |
testcase_10 | AC | 132 ms
88,576 KB |
testcase_11 | AC | 136 ms
88,504 KB |
testcase_12 | AC | 135 ms
88,576 KB |
testcase_13 | AC | 139 ms
88,448 KB |
testcase_14 | AC | 138 ms
88,516 KB |
testcase_15 | AC | 136 ms
88,320 KB |
testcase_16 | AC | 133 ms
88,648 KB |
testcase_17 | AC | 130 ms
88,320 KB |
testcase_18 | AC | 188 ms
89,316 KB |
testcase_19 | AC | 199 ms
89,452 KB |
testcase_20 | AC | 134 ms
88,576 KB |
testcase_21 | AC | 139 ms
88,520 KB |
testcase_22 | AC | 192 ms
89,472 KB |
testcase_23 | AC | 139 ms
88,576 KB |
testcase_24 | AC | 140 ms
88,360 KB |
testcase_25 | AC | 136 ms
88,576 KB |
testcase_26 | AC | 134 ms
88,640 KB |
testcase_27 | AC | 135 ms
88,576 KB |
testcase_28 | AC | 136 ms
88,576 KB |
testcase_29 | AC | 139 ms
88,224 KB |
testcase_30 | AC | 140 ms
88,508 KB |
testcase_31 | AC | 142 ms
88,576 KB |
testcase_32 | AC | 224 ms
89,596 KB |
testcase_33 | AC | 226 ms
89,600 KB |
testcase_34 | AC | 321 ms
89,848 KB |
testcase_35 | AC | 323 ms
89,984 KB |
testcase_36 | AC | 325 ms
89,728 KB |
testcase_37 | AC | 317 ms
89,984 KB |
testcase_38 | AC | 330 ms
89,908 KB |
testcase_39 | AC | 309 ms
89,984 KB |
testcase_40 | AC | 321 ms
90,008 KB |
testcase_41 | AC | 326 ms
89,780 KB |
testcase_42 | AC | 330 ms
90,044 KB |
testcase_43 | AC | 316 ms
89,520 KB |
testcase_44 | AC | 334 ms
89,728 KB |
testcase_45 | AC | 322 ms
89,840 KB |
testcase_46 | AC | 330 ms
89,728 KB |
testcase_47 | AC | 342 ms
89,984 KB |
testcase_48 | AC | 333 ms
89,888 KB |
testcase_49 | AC | 317 ms
89,984 KB |
testcase_50 | AC | 323 ms
89,856 KB |
testcase_51 | AC | 323 ms
89,856 KB |
testcase_52 | AC | 333 ms
89,792 KB |
testcase_53 | AC | 332 ms
89,984 KB |
testcase_54 | AC | 207 ms
89,728 KB |
testcase_55 | AC | 211 ms
89,676 KB |
testcase_56 | AC | 140 ms
88,448 KB |
testcase_57 | AC | 135 ms
88,448 KB |
testcase_58 | AC | 138 ms
88,564 KB |
testcase_59 | AC | 140 ms
88,448 KB |
testcase_60 | AC | 142 ms
88,576 KB |
testcase_61 | AC | 140 ms
88,440 KB |
testcase_62 | AC | 137 ms
88,192 KB |
testcase_63 | AC | 142 ms
88,588 KB |
testcase_64 | AC | 141 ms
88,576 KB |
testcase_65 | AC | 141 ms
88,500 KB |
testcase_66 | AC | 205 ms
89,844 KB |
testcase_67 | AC | 140 ms
88,576 KB |
testcase_68 | AC | 210 ms
89,644 KB |
testcase_69 | AC | 145 ms
88,084 KB |
testcase_70 | AC | 216 ms
89,944 KB |
testcase_71 | AC | 137 ms
88,576 KB |
testcase_72 | AC | 130 ms
88,140 KB |
testcase_73 | AC | 129 ms
88,428 KB |
testcase_74 | AC | 132 ms
88,320 KB |
testcase_75 | AC | 130 ms
88,508 KB |
testcase_76 | AC | 129 ms
88,576 KB |
testcase_77 | AC | 130 ms
88,204 KB |
testcase_78 | AC | 134 ms
88,432 KB |
testcase_79 | AC | 133 ms
88,512 KB |
testcase_80 | AC | 197 ms
89,756 KB |
testcase_81 | AC | 134 ms
88,544 KB |
testcase_82 | AC | 201 ms
89,880 KB |
testcase_83 | AC | 134 ms
88,448 KB |
testcase_84 | AC | 133 ms
88,504 KB |
testcase_85 | AC | 137 ms
88,228 KB |
testcase_86 | AC | 180 ms
89,472 KB |
testcase_87 | AC | 131 ms
88,636 KB |
ソースコード
import fractions n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) D = list(map(int, input().split())) X_ind = sorted(range(n), key=lambda i: fractions.Fraction(A[i], B[i])) Y_ind = sorted(range(n), key=lambda i: fractions.Fraction(C[i], D[i])) S = [(fractions.Fraction(0), fractions.Fraction(0))] for i in X_ind: S.append((S[-1][0] + A[i], S[-1][1] + B[i])) T = [(fractions.Fraction(0), fractions.Fraction(0))] for i in Y_ind: T.append((T[-1][0] + C[i], T[-1][1] + D[i])) def cross3(a, b, c): return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]) def iscross(a1, a2, b1, b2): flg1 = cross3(a1, a2, b1) * cross3(a1, a2, b2) < 0 flg2 = cross3(b1, b2, a1) * cross3(b1, b2, a2) < 0 return flg1 and flg2 if fractions.Fraction(*S[1]) > fractions.Fraction(*T[1]): print("No") exit() for i in range(n + 1): for j in range(n): res = cross3(S[j], S[j + 1], T[i]) if res > 0: print("No") exit() def f(P1, P2): y1, x1 = P1 y2, x2 = P2 a = (y1 - y2) / (x1 - x2) b = y1 - a * x1 return a, b cnt = 1 p = 0 p2 = 1 y = fractions.Fraction(0) x = fractions.Fraction(0) # print(T) # print(S) while p < n: # print("+++", cnt, y, x, p, p2) res = cross3((y, x), T[p], T[p + 1]) if res >= 0: p += 1 continue cnt += 1 while 1: # print(y, x, p, p2, T[p]) # print(S[p2], S[p2 + 1]) r1 = cross3((y, x), T[p], S[p2]) r2 = cross3((y, x), T[p], S[p2 + 1]) # print(p, p2, r1, r2) if r1 * r2 <= 0: break p2 += 1 a, b = f((y, x), T[p]) c, d = f(S[p2], S[p2 + 1]) # print(y, x, T[p], S[p2], S[p2 + 1]) # print(a, b, c, d) if a == c: y, x = S[p2 + 1] else: y = (a * d - b * c) / (a - c) x = (d - b) / (a - c) p += 1 p2 += 1 if cnt < n: print("Yes") exit() for i in range(n): for j in range(i + 1, n): if (fractions.Fraction(A[i], B[i]) > fractions.Fraction(A[j], B[j])) and ( fractions.Fraction(C[i], D[i]) < fractions.Fraction(C[j], D[j]) ): print("No") exit() if (fractions.Fraction(A[i], B[i]) < fractions.Fraction(A[j], B[j])) and ( fractions.Fraction(C[i], D[i]) > fractions.Fraction(C[j], D[j]) ): print("No") exit() print("Yes")