Silly greedy problem.
First, according to the order of the points from the big to the small, the same score according to the cutoff date from small to large order. Then, in order, start looking for the time that is not occupied from the due date. If you cannot find it, add it to the penalty points.
# 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++) SC ANF ("%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 Summer Camp Training 2 I question Doing homework again