---
# System prepended metadata

title: 寒假Apcs訓練 1/29

---

c471. apcs 物品堆疊 (Stacking)
===
貪心算法 花費性價比最多放最上面
---
```python=
n = int(input())
w = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a = [[w[i]/f[i],w[i],f[i]] for i in range(n) if f[i] != 0]
a.sort()
ans = 0
total = 0
for i in a:
    ans += total * i[2]
    total += i[1]
print(ans)

```
