标签:
傻逼贪心题。
# include <stdio.h> # include <stdlib.h> # include <string.h> int h[1005][2], n, visit[1005]; int comp(const void * a, const void * b) { return *(((int*)b)+1) - *(((int *)a)+1); } int main (void) { int t, i, j, day, sum, min, v; scanf("%d",&t); while (t--) { scanf("%d",&n); for (i=0; i<n; i++) scanf("%d",&h[i][0]); for (i=0; i<n; i++) scanf("%d",&h[i][1]); qsort(h,n,sizeof(h[0]),comp); memset(visit,0,sizeof(visit)); for (i=0, sum=0; i<n; i++) { for (j=h[i][0]; j>0; j--) { if (visit[j] == 0) { visit[j] = 1; break; } } if (j == 0) sum += h[i][1]; } printf("%d\n",sum); } return 0; }
2016暑假集训训练2 I题 Doing Homework again
标签:
原文地址:http://www.cnblogs.com/lishiyao/p/5697094.html