2016 Summer Camp Training 2 I question Doing homework again

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.