问题2467--Kuangyeye and hamburgers2467: Kuangyeye and hamburgers
时间限制: 1 Sec 内存限制: 128 MB
提交: 1 解决: 1
[提交] [状态] [讨论版] [命题人:]题目描述
Kuangyeye is a dalao of the ACM school team of Hunan University. His favorite food are hamburgers. One day, Kuangyeye came to the KFC(or maybe McDonald) and saw n hamburgers on the counter.The weight of the i-th hamburger was wi. Since he likes hamburgers very much, he would like to buy some hamburgers. Considering his weight or other factors, Kuangyeye only wanted to eat all the hamburgers from the a-th heaviest to the b-th. Since Kuangyeye is fickle, he had k plans before buying hamburgers. The i-th plan gives ai and bi. Please help Kuangyeye calculate the maximum weight of hamburgers he can eat among the k plans.
输入
the first line of input contains two integer n and k--the number of hamburgers on the counter and the number of plans Kuangyeye had;
the next line contains n integer--the i-th integer represents the weight of i-th hamburger,namely wi;
Each the following k line contains two integer ai and bi ,represents Kuangyeye's strategy in his i-th plan.
输出
Output contain a single integer,represents maximum weight of hamburgers Kuangyeye can eat.
样例输入
5 2
4 3 5 2 6
1 1
3 4
样例输出
7
提示
Kuangyeye's first plan was to eat the hamburger weighing 6;
and his second plan was to eat the hamburger weighing 3 and 4;
So the maximum weight of hamburgers he can eat was 7.
1≤n,k≤100000,1≤ai≤bi≤n,1≤wi≤10000
来源/分类
[提交] [状态]