結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー ygd.ygd.
提出日時 2020-10-17 20:18:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 375 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 135,356 KB
最終ジャッジ日時 2024-07-21 03:03:01
合計ジャッジ時間 18,088 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

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