csu 1603: Scheduling the final examination(贪心)
来源:互联网 发布:织梦cms安装教程 编辑:程序博客网 时间:2024/04/27 15:41
1603: Scheduling the final examination
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 43 Solved: 12
[Submit][Status][Web Board]
Description
For the most of the university students,what they most want is that they can obtain 60 points from the final examination of every subject. Now, final examination is coming. As an excellent programmer,you are asked for help. The full mark is 100, and it is need greater than or equal to 60 to pass subjects. Given the description of every subject, you should schedule the time of review to every subject in order to pass every subject and at the same time to obtain the higher total scores as possible.
Input
The input consists of multiple test cases. For each test case, the first line is an integer n (1<=n<=50), which is the number of subjects. Then n lines follow, each line has four integers si, ti, ai, di to describe the subject. si(0<=si<=100):the score that he can obtained without reviewing,ti(1<=ti<720):the time of examination,
ai(1<=ai<=40):the first hour reviewing on this subject will improve ai scores,di(0<=di<=4):the improving scores will decrease di every reviewing hour. For example,when ai = 10, di = 2, the first hour viewing will improve 10 scores , and the second hour viewing will only improve 8 scores.
Output
For each test case, to output in one line. If he can pass all the subjects, please output an integer which is the highest total scores, otherwise please output a string “you are unlucky”.
Sample Input
158 3 5 3158 1 5 3440 6 10 250 9 10 260 3 4 270 1 4 2442 6 10 250 9 10 254 3 4 270 1 4 2430 6 10 250 9 10 254 3 4 270 1 4 2
Sample Output
6563280274you are unlucky
先让所有考试的分数都能到达60 然后选取当前a值最大的考试进行复习。。。
#include<cstdio>#include<cstdlib>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#include<vector>#include<set>#include<map>using namespace std;#define REP(x, y) for(int x = 0; x < y; x++)#define DWN(x, y) for(int x = y-1; x > -1; x--)struct Exam{ int s,t,a,d; int add() { if(100-s>a) return a; else return 100-s; }}ex[60]; int timer[750]; int main(){// freopen("D.in", "r", stdin); int n; while(scanf("%d",&n)!=EOF) { int mx=-1; memset(timer,0,sizeof timer); for(int i=0;i<n;i++) { scanf("%d%d%d%d",&ex[i].s,&ex[i].t,&ex[i].a,&ex[i].d); mx=max(mx,ex[i].t); int t=ex[i].t; while(t>0&&ex[i].s<60&&ex[i].a>0) { if(timer[t]==0) { ex[i].s+=ex[i].add(); ex[i].a-=ex[i].d; timer[t]=1; } t--; } } for(int i=720;i>0;i--) { if(!timer[i]) { int m=-1; for(int j=0;j<n;j++) { if(ex[j].t>=i&&(m==-1||ex[m].add()<ex[j].add())) m=j; } if(m!=-1&&ex[m].a>0) { ex[m].s+=ex[m].add(); ex[m].a-=ex[m].d; } } } int ans=0; int flag=1; for(int i=0;i<n;i++) { if(ex[i].s>=60) ans+=ex[i].s; else { flag=0; break; } } if(flag) printf("%d\n",ans); else puts("you are unlucky"); } return 0;} /************************************************************** Problem: 1603 User: youngkl Language: C++ Result: Accepted Time:8 ms Memory:1488 kb****************************************************************/
- csu 1603: Scheduling the final examination(贪心)
- CSU 1603 Scheduling the final examination(贪心)
- CSU 1603: Scheduling the final examination
- CSU1603: Scheduling the final examination(贪心)
- HDUPhysical Examination(贪心)
- HDU-#4442 Physical Examination(贪心)
- hdu 4442 Physical Examination(贪心)
- HDU 4442 - Physical Examination(贪心)
- hdu 4442 Physical Examination(贪心)
- HDU 4442 Physical Examination (贪心选择)
- HDU 4442 Physical Examination(贪心)
- hdu 4442 Physical Examination (贪心)
- strange final examination
- UVa 607 Scheduling Lectures(DP, 贪心)
- Uva 607 Scheduling Lectures (Dp+贪心)
- UVA 607-Scheduling Lectures(贪心+DP)
- the classical examination test
- 贪心--HDU - 4442 Physical Examination
- visual studio 快捷键设置
- 我的笔记
- Git操作-分支管理(三)
- learn python the hard way ----学习笔记(2)
- git push被拒绝的处理方式
- csu 1603: Scheduling the final examination(贪心)
- NSArray和NSMutableArray
- 李开复给中国大学生的第五封信—你有选择的权利
- UI学习笔记一
- [POJ] 2318 -> TOYS
- p123第29题(输出下标为3456的数)
- setTimeout和setInterval
- Linux的五个查找命令
- PHP 较全面的mysql.class.php