NYOJ 757 期末考试(优先队列)
来源:互联网 发布:勇者之塔数据大全 编辑:程序博客网 时间:2024/06/01 08:59
期末考试
时间限制:1000 ms | 内存限制:65535 KB
难度:2
- 描述
- 马上就要考试了,小T有许多作业要做,而且每个老师都给出来了作业要交的期限,如果在规定的期限内没交作业就会扣期末成绩的分数,假设完成每门功课需要一天的时间,你能帮助小T扣除的分数最小吗?
- 输入
- 输入n,表示n门功课(n<2000),接下来n行,每行两个数a,b,分别表示交作业的最后期限,迟交扣除的分数。
(以文件结尾) - 输出
- 输出扣除的最小分数。
- 样例输入
33 103 53 131 63 21 371 34 26 14 72 64 53 4
- 样例输出
035
不解释的一道题
ac代码:
#include <stdio.h>#include <algorithm>#include <queue>using namespace std;struct node {int time,value;}d[2005];bool cmp(node x,node y){if(x.time==y.time)return x.value<y.value;return x.time<y.time;}int main(){int n,sum;priority_queue<int,vector<int>,greater<int> >s;while(scanf("%d",&n)!=EOF){while(!s.empty())s.pop();for(int i=0;i<n;i++)scanf("%d %d",&d[i].time,&d[i].value);sort(d,d+n,cmp);sum=0;for(int i=0;i<n;i++){if(s.size()<d[i].time)s.push(d[i].value);else{int x=s.top();if(x<d[i].value)//总是用价值最大的把价值最小的替换出来{s.pop();s.push(d[i].value);sum+=x;}elsesum+=d[i].value;}}printf("%d\n",sum);}return 0;}
0 0
- NYOJ 757 期末考试(优先队列)
- nyoj 757 期末考试【优先队列】【快排】
- nyoj 757 期末考试 【STL 优先队列】
- 期末考试(优先队列)
- nyoj757 期末考试 (优先队列)
- 南阳oj 757 期末考试【优先队列+sort排序】
- nyoj 55(优先队列)
- NYOJ 题目757 期末考试(贪心)
- NYOJ 757期末考试
- NYOJ 757 期末考试【贪心】
- NYOJ-757-期末考试
- 期末考试--nyoj-757
- NYOJ 754 黑心医生(优先队列)
- NYOJ-284坦克大战(优先队列)
- NYOJ 635优先队列
- nyoj 547 优先队列
- 【NYOJ 284 BFS+优先队列】
- NYOJ 284 优先队列 搜索
- 关于新项目部署的若干问题
- oracle坏块及解决办法
- HDU 2037:今年暑假不AC
- 重学java23种设计模式(9)装饰者模式
- GET和POST的区别
- NYOJ 757 期末考试(优先队列)
- ios D-U-N-S Number(邓白氏编码)申请
- JavaScript学习总结
- NY 55 懒省事的小明 【队列】
- UVa 1643 - Angle and Squares(叉乘求面积)
- MyEclipse 使用技巧
- VC 中char 与 wchar的转换
- SZTextView 不能输入中文解决方法
- UI中获取图片的三种方式