Hdu1789: doing homework again

Source: Internet
Author: User
Problem descriptionignatius 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 Ignatius 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 Ignatius wants you to help him to arrange the order of doing homework to minimize the already CED score.

Inputthe 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 specified CED
Scores.

Outputfor each test case, You shoshould output the smallest total balanced CED score, one line per test case.

Sample Input

333 3 310 5 131 3 16 2 371 4 6 4 2 4 33 2 1 7 6 5 4
 

Sample output

035
 

 

# Include <iostream> # include <algorithm> # include <cstring> using namespace STD; struct node {int time, fen;} node [1005]; int CMP (struct node, struct Node B) {if (. fen! = B. FEN) return. fen> B. fen; // return. time <B. time; // when the deduction points are the same, the earlier the deadline, the higher the front} int visit [2010]; // if it is not used on the day, the value is 0; otherwise, it is 1int main () {int m; CIN> m; while (M --) {int N, I, j, ANS = 0; memset (visit, 0, sizeof (visit )); cin> N; for (I = 0; I <n; I ++) {CIN> node [I]. time ;}for (I = 0; I <n; I ++) {CIN> node [I]. fen;} Sort (node, node + N, CMP); int sum = 0; for (I = 0; I <n; I ++) {J = node [I]. time; // push forward from the End Time, If you haven't used this course one day, you can take this course one day. This course does not deduct points while (j) {If (! Visit [J]) {visit [J] = 1; break;} j --;} If (j = 0) // If J = 0, it indicates that every day from time has been occupied. This course cannot be completed by ans + = node [I]. fen;} cout <ans <Endl;} return 0 ;}

 

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.