結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー ygd.ygd.
提出日時 2020-10-17 20:18:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 134,608 KB
最終ジャッジ日時 2023-09-28 08:34:07
合計ジャッジ時間 22,404 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,324 KB
testcase_01 AC 71 ms
71,404 KB
testcase_02 AC 71 ms
71,416 KB
testcase_03 AC 72 ms
71,460 KB
testcase_04 AC 71 ms
71,208 KB
testcase_05 AC 71 ms
71,340 KB
testcase_06 AC 71 ms
71,504 KB
testcase_07 AC 70 ms
71,196 KB
testcase_08 AC 71 ms
71,092 KB
testcase_09 AC 72 ms
71,440 KB
testcase_10 AC 69 ms
71,408 KB
testcase_11 AC 72 ms
71,244 KB
testcase_12 AC 72 ms
71,432 KB
testcase_13 AC 69 ms
71,460 KB
testcase_14 AC 70 ms
71,316 KB
testcase_15 AC 72 ms
71,316 KB
testcase_16 AC 71 ms
71,240 KB
testcase_17 AC 70 ms
71,508 KB
testcase_18 AC 396 ms
134,608 KB
testcase_19 AC 380 ms
129,700 KB
testcase_20 AC 220 ms
101,716 KB
testcase_21 AC 90 ms
76,624 KB
testcase_22 AC 229 ms
99,880 KB
testcase_23 AC 88 ms
76,576 KB
testcase_24 AC 287 ms
111,812 KB
testcase_25 AC 227 ms
100,596 KB
testcase_26 AC 126 ms
88,096 KB
testcase_27 AC 89 ms
76,564 KB
testcase_28 AC 408 ms
133,504 KB
testcase_29 AC 411 ms
133,452 KB
testcase_30 AC 421 ms
133,692 KB
testcase_31 AC 405 ms
133,416 KB
testcase_32 AC 408 ms
133,792 KB
testcase_33 AC 410 ms
133,628 KB
testcase_34 AC 410 ms
133,524 KB
testcase_35 AC 406 ms
133,372 KB
testcase_36 AC 406 ms
133,308 KB
testcase_37 AC 413 ms
133,716 KB
testcase_38 AC 409 ms
133,668 KB
testcase_39 AC 408 ms
133,424 KB
testcase_40 AC 406 ms
133,696 KB
testcase_41 AC 415 ms
133,460 KB
testcase_42 AC 406 ms
133,360 KB
testcase_43 AC 70 ms
71,416 KB
testcase_44 AC 74 ms
71,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = []
b = 0; a = 0 #bx+a
for i in range(N):
  temp = (A[i],B[i])
  b -= B[i]; a += B[i]*A[i]
  C.append(temp)
C.sort(key=lambda x: x[0])
#print(C)
#Flag = True #負の数
#print(b,a)
for i in range(N):
  b += 2*C[i][1] #i番目のb
  a -= 2*C[i][0]*C[i][1]
  #print(b,a)
  if b >= 0:
    ans = b*C[i][0]+a
    print(C[i][0],ans);exit()
0