Greedy Doing Homework again

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1789

1 /*2 Doing Homework again3 The most points of the first arrangement, arranged on the day of the absence of the Mission4 */5#include <iostream>6#include <algorithm>//void Sort (randomit first, Randomit last, Compare comp);7 using namespacestd;8 #defineMax_num 10059 Ten structHomework One { A     intDay ; -     intscore; - }homework[max_num]; the BOOLcmpstructHomework A,structHomework B) - { -     returnA.score > B.score?1:0; - } + intMain () - { +     intT; ACIN >>T; at      while(t--) -     { -         intI, visit[max_num] = {0}, Homework_num =0, score =0, Max_score =0; -CIN >>Homework_num; -          for(i =0; i < Homework_num; i++) -CIN >>Homework[i].day; in          for(i =0; i < Homework_num; i++) -         { toCIN >>Homework[i].score; +Max_score + =Homework[i].score; -         } theSort (homework, homework +Homework_num, CMP); *          for(i =0; i < Homework_num; i++) $         {Panax Notoginseng             intD =Homework[i].day; -              for(; d >=1; d--) the             { +                 if(Visit[d] = =0) A                      Break; the             } +             if(Visit[d] = =0&& d >0)//is it possible to schedule this day -             { $VISIT[D] =1; $Score + =Homework[i].score; -             } -         } thecout << (Max_score-score) << Endl;//minimum number of points to be deducted last -     }Wuyi  the     return 0; -}

Greedy 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.