Poj 1042 phishing enumeration + greedy

Source: Internet
Author: User

# Include <stdio. h> <br/> # include <string. h> <br/> int f [25]; // the first fish that can be caught in five minutes <br/> int CURF [25]; // currently, the number of fish caught in each lake <br/> int d [25]; // The number of fish caught in each five minutes <br/> int ans [25]; // The duration of each lake when the maximum number of fish can be caught <br/> int anstmp [25]; <br/> int T [25]; // time required to move from I to I + 1 <br/> int N; <br/> int times; // total fishing time <br/> int restimes; // total fishing time-time spent walking between lakes <br/> int fish; // maximum number of fish to be caught <br/> int fishtmp; <br/> int main () {<br/> while (scanf ("% d", & N )! = EOF & n! = 0) {<br/> scanf ("% d", ×); <br/> for (INT I = 0; I <n; I ++) <br/> scanf ("% d", & F [I]); <br/> for (INT I = 0; I <n; I ++) <br/> scanf ("% d", & D [I]); <br/> for (INT I = 1; I <n; I ++) <br/> scanf ("% d", & T [I]); <br/> T [0] = 0; <br/> times * = 12; <br/> restimes = 0; <br/> fish = 0; <br/> memset (ANS, 0, sizeof (ANS )); <br/> for (INT Len = 1; Len <= N; Len ++) {<br/> memcpy (CURF, F, sizeof (f )); <br/> memset (anstmp, 0, sizeof (anstmp); <br/> restimes + = T [Len-1]; <br/> fishtmp = 0; <br/> for (INT I = 1; I <= times-restimes; I ++) {<br/> int _ Maxi = 0; <br/> for (Int J = 1; j <Len; j ++) <br/> If (CURF [J]> CURF [_ Maxi]) <br/> _ Maxi = J; <br/> anstmp [_ Maxi] ++; <br/> fishtmp + = CURF [_ Maxi]; <br/> CURF [_ Maxi]-= d [_ Maxi]; <br/> If (CURF [_ Maxi] <0) <br/> CURF [_ Maxi] = 0; <br/>}< br/> If (fishtmp> fish) {<br/> fish = fishtmp; <br/> memcpy (ANS, anstmp, sizeof (anstmp); <br/>} else if (fishtmp = fish) {<br/> for (INT I = 0; I <Len; I ++) {<br/> If (ANS [I]> anstmp [I]) break; // if you forget this sentence, an error may occur when multiple solutions are implemented. wa3 times later, you will find that <br/> If (ANS [I] <anstmp [I]) {<br/> memcpy (ANS, anstmp, sizeof (anstmp); <br/> break; <br/>}< br/> printf ("% d", ANS [0] * 5 ); <br/> for (INT I = 1; I <n; I ++) <br/> printf (", % d", ANS [I] * 5 ); <br/> printf ("/nNumber of fish expected: % d/n", fish); <br/>}< br/> return 0; <br/>}< br/> 

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.