MOBIVINA - MobiZone vs VinaGone

KTuan and AnhDQ, CEOs of two telecommunication corporations MobiZone and VinaGone have signed a contract to use their network in common. N people have accepted to try this new service. The ith people accepts to pay Mi to use MobiZone's service or Vi to use VinaGone's one; and any two people ith and jth accept to pay Cij in common whether they use different services (the network cost).

Request

Find a way of choosing networks for N people satisfying the sum of total cost is minimum.

Input

- The first line contains number N.
- The second line contains N number(s) Mi.
- The third line contains N number(s) Vi.
- The last N line(s), each of them contains N number(s) Cij (Cij = Cji).

Output

- Contains the minimum total cost.

Example

Input:
3
1 1 10
10 10 1
0 0 1
0 0 1
1 1 0

Output:
5

Limitations

- N ≤ 250.
- The remaining numbers of Input do not exceed 1000.


Được gửi lên bởi:AnhDQ
Ngày:2009-06-08
Thời gian chạy:0.100s-1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:Mr Tuan Khuc Anh - NTU (Singapore)

hide comments
2020-02-24 05:05:03
hi
2019-09-16 10:13:58
Duc M. Pham ga thi tle thoi chu sao ^O^ ><
2015-03-17 17:20:04 Duc M. Pham
Bài này siết time quá :v Thuật thì không có gì khó mà TLE miết
2009-06-08 16:01:29 AnhDQ
đọc là [mô-bi-zon] và [vi-na-gon] nhé :))
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.