Doing Homework again
2016-07-26 13:14
281 查看
Doing Homework again
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
HDU 1789
Description
zichen has just come back school from the 30th ACM/ ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If zichen hands in the homework after the deadline, the teacher will reduce his score of the final test. And now we assume that doing everyone homework always takes one day. So zichen wants you to help him to arrange the order of doing homework to minimize the reduced score.
Input
The input contains several test cases. The first line of the input is a single integer T that is the number of test cases. T test cases follow.
Each test case start with a positive integer N(1<=N<=1000) which indicate the number of homework.. Then 2 lines follow. The first line contains N integers that indicate the deadlines of the subjects, and the next line contains N integers that indicate the reduced scores.
Output
For each test case, you should output the smallest total reduced score, one line per test case.
Sample Input
3
3 3 3
10 5 1
3
1 3 1
6 2 3
7
1 4 6 4 2 4 3
3 2 1 7 6 5 4
Sample Output
3
5
FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM
Anything about the OJ, please ask in the forum, or contact author:Isun
Server Time: 2016-07-26 13:10:47
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
HDU 1789
Description
zichen has just come back school from the 30th ACM/ ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If zichen hands in the homework after the deadline, the teacher will reduce his score of the final test. And now we assume that doing everyone homework always takes one day. So zichen wants you to help him to arrange the order of doing homework to minimize the reduced score.
Input
The input contains several test cases. The first line of the input is a single integer T that is the number of test cases. T test cases follow.
Each test case start with a positive integer N(1<=N<=1000) which indicate the number of homework.. Then 2 lines follow. The first line contains N integers that indicate the deadlines of the subjects, and the next line contains N integers that indicate the reduced scores.
Output
For each test case, you should output the smallest total reduced score, one line per test case.
Sample Input
3
3
3 3 3
10 5 1
3
1 3 1
6 2 3
7
1 4 6 4 2 4 3
3 2 1 7 6 5 4
Sample Output
0
3
5
FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM
Anything about the OJ, please ask in the forum, or contact author:Isun
Server Time: 2016-07-26 13:10:47
#include<cstdio> #include<algorithm> using namespace std; struct node{ int day; int sco; bool k; }a[1011]; bool cmp(node a,node b){ if(a.day==b.day) return a.sco>b.sco; return a.day<b.day; } int main(){ int T;scanf("%d",&T); while(T--){ int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i].day); for(int i=0;i<n;i++){ scanf("%d",&a[i].sco); a[i].k=true; } sort(a,a+n,cmp); int sum=0; int k=1; for(int i=0;i<n;i++){ if(a[i].day>=k){ k++; continue ; } int min=a[i].sco; int s=i; for(int j=0;j<i;j++){ if(min>a[j].sco&&a[j].k){ min=a[j].sco; s=j; } } sum+=min; a[s].k=false; } printf("%d\n",sum); } return 0; }
相关文章推荐
- saiku 修改默认图表颜色
- http://www.caogen.com/blog/Infor_detail/83263.html
- intellj vailad code
- org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter
- Gtk-Message: Failed to load module "canberra-gtk-module"
- opencv Haartraining
- 将GPS坐标转换成百度地图坐标,将baidu 经纬度 转换为google经纬度
- [219] Contains Duplicate II
- pthread_key泄露问题检测
- (HDU 5728)2016 Multi-University Training Contest 1 PowMod(数论)
- 1086. Tree Traversals Again (25)
- 游戏编程中的人工智能技术-扫雷机系列
- SLA by Short brain-July-2016
- 7.5 obtaining database metadata
- HDU 4300 Clairewd’s message 扩展kmp || kmp
- (LeetCode)Contains Duplicate -- 查看数组是否重复
- hihocoder #1341 Constraint Checker
- 杭电-1702 ACboy needs your help again!(栈&队列)
- POJ1363:Rails(栈)
- poj 1363 Rails 【栈】