Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
NKPANO - Billboard painting |
English | Vietnamese |
A group of K painters has to paint a rectangular billboard of size 1xN. The billboard is divided into N cells of size 1x1. The cells are numbered from 1 to N in left to right order.
The i-th painter (1 ≤ i ≤ K) is currently standing in front of the cell Si. He either can paint no cells at all or can paint a consecutive number of cells that must containt the cell Si. Moreover, he can only paint at most Li cells, and for each painted cell, he will receive a payment of Pi dollars. Each cell can be painted by at most one person.
Your task is to find a way for the painters to receive the largest amount of payment.
Input
- The first line of the input contains two positive integers N, K (N ≤ 16000; K ≤ 100).
- The i-th line of the next K lines contains three positive integers Li , Pi, Si (i = 1, 2, … K) separated by spaces (1 ≤ Pi ≤ 10000, 1 ≤ Li , Si ≤ N ). The numbers S1, S2, . . . SK are pairwise distinct.
Output
A single line contains the largest payment that the painters can receive.
Example
Input 8 4 3 2 2 3 2 3 3 3 5 1 1 7 Output 17
The first painter will paint the first two cells, the second painter will paint the next two cells, the third one will paint the remaining cells and the last won't have to paint any cells.
Được gửi lên bởi: | Jimmy |
Ngày: | 2008-01-13 |
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: | Prof. Nguyen Duc Nghia |
hide comments
2020-08-23 15:25:04
https://pastebin.com/nD2Zw2iQ - Đệ thầy Hoàng - |
|
2016-12-23 08:54:18 xin đừng quên tôi
THAM KHẢO THUẬT TOÁN VÀ CODE TẠI: http://yeulaptrinh.pw/549/nkpano-spoj/ |
|
2016-09-08 11:45:46
I'm allowed to delete the post and use html code here.| |
|
2015-07-25 13:08:27 there's no salvation for me...
làm IT time nhỏ vãi =))) |
|
2014-12-23 13:53:08 Nghiêm Vãn Long
cho e xin bafi tham khao, gmail : vochandoiqua@gmail.com |
|
2014-08-06 01:47:57 ■■‡[ND] Bee Sociu■■‡
Please be careful, leave short comments only. Don't spam here. |
|
2014-06-30 05:54:21 ๖ۣۜPublic °°
Bài này duyệt là được 20% nha các bạn. ai muốn tham khảo có thể gửi mail cho t. :v Last edit: 2014-06-30 11:28:21 |
|
2014-05-07 20:52:25 an IM3 Ex-Member of Bit
Test yếu, một số chương trình sai vẫn AC. |
|
2014-04-17 07:17:16 Trần Duy Lực
Quy hoạch động . |