Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
MPILOT - Pilots |
English | Vietnamese |
Charlie acquired airline transport company and to stay in business he needs to lower the expenses by any means possible. There are N pilots working for his company (N is even) and N/2 plane crews needs to be made. A plane crew consists of two pilots - a captain and his assistant. A captain must be older than his assistant. Each pilot has a contract granting him two possible salaries - one as a captain and the other as an assistant. A captain's salary is larger than assistant's for the same pilot. However, it is possible that an assistant has larger salary than his captain. Write a program that will compute the minimal amount of money Charlie needs to give for the pilots' salaries if he decides to spend some time to make the optimal (i.e. the cheapest) arrangement of pilots in crews.
Input
The first line of input contains integer N, 2 ≤ N ≤ 10,000, N is even, the number of pilots working for the Charlie's company. The next N lines of input contain pilots' salaries. The lines are sorted by pilot's age, the salaries of the youngest pilot are given the first. Each of those N lines contains two integers separated by a space character, X i Y, 1 ≤ Y < X ≤ 100,000, a salary as a captain (X) and a salary as an assistant (Y).
Output
The first and only line of output should contain the minimal amount of money Charlie needs to give for the pilots' salaries.
Sample
input 4 5000 3000 6000 2000 8000 1000 9000 6000 output 19000
input 6 10000 7000 9000 3000 6000 4000 5000 1000 9000 3000 8000 6000 output 32000
Được gửi lên bởi: | psetter |
Ngày: | 2009-04-25 |
Thời gian chạy: | 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: | COI 04 |
hide comments
|
|||||
2021-05-27 18:02:00
Tham khảo: https://vnspoj.github.io/problems/MPILOT |
|||||
2021-04-15 18:25:55
qhđ hay uwu :)) |
|||||
2020-07-25 13:16:46
TranTrungKienGoldIOI2021 |
|||||
2019-10-19 12:50:27
http://eunsetee.com/Y5An |
|||||
2019-08-25 12:25:00
heap cơ bản nhé anh em . code : https://ideone.com/4jA4OG |
|||||
2019-08-02 07:30:29
Có một trợ lí có thể có lương cao hơn đội trưởng nha đề bên này dịch thiếu -_- |
|||||
2019-06-04 16:04:50
cho mình hỏi ở test case 2, đề ghi rõ là phi công chính lớn tuổi hơn trợ lý, nếu đúng thì mình thử thấp nhất là 34000, còn nếu bỏ điều kiện đó đi thì mình mới ra 32000, liệu có sai đề không mọi người |
|||||
2019-01-25 16:49:02
Cảm ơn code mẫu ở dưới nhiều ạ |
|||||
2018-06-29 10:47:45
Xem công thức qhđ và code: https://vietcodes.github.io/code/145/ |
|||||
2018-02-12 14:24:58 Sơn Tùng M-TP
Quy hoạch động như bài C11KM cũng được nè. Mà mỗi tội tốn hơi nhiều bộ nhớ. |