您的位置:首页 > 大数据 > 人工智能

【杭电1789】Doing Homework again

2016-07-22 20:37 302 查看




#include<stdio.h>
#include<algorithm>
using namespace std;
struct note {
int day;
int score;//分数
bool mark;
} s[1006];
bool judge(note a,note b) {
if(a.day==b.day)
return a.score>b.score;
return a.day<b.day;
}
int main() {
int T;
scanf("%d",&T);
while(T--) {
int n;
scanf("%d",&n);
for(int l=0; l<n; l++)
scanf("%d",&s[l].day);
for(int l=0; l<n; l++) {
scanf("%d",&s[l].score);
s[l].mark=true;
}
sort(s,s+n,judge);
int k=1,sum=0;
for(int l=0; l<n; l++) {
if(s[l].day>=k) {
k++;
continue;
}
int t=s[l].score,w=l;
for(int j=0; j<l; j++)
if(s[j].score<t&&s[j].mark) {
t=s[j].score;
w=j;
}
sum=sum+t;
s[w].mark=false;
}
printf("%d\n",sum);
}
return 0;
}


http://acm.hdu.edu.cn/showproblem.php?pid=1789
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  杭电