Greedy UVA 11729 Commando War

Source: Internet
Author: User

Topic Portal

1 /*2 greedy: Sort by precedence over long execution times3 */4#include <cstdio>5#include <algorithm>6#include <iostream>7#include <cstring>8#include <string>9#include <cmath>Ten using namespacestd; One  A Const intMAXN = 1e3 +Ten; - Const intINF =0x3f3f3f3f; - structNode { the     intb, J; -     BOOL operator< (ConstNode &r)Const { -         returnJ >R.J; -     } + }NODE[MAXN]; -  + intMainvoid)//UVA 11729 Commando War A { at     //freopen ("uva_11729.in", "R", stdin); -  -     intNintCAS =0; -      while(SCANF ("%d", &n) = =1&&N) -     { -          for(intI=1; i<=n; ++i) in         { -scanf ("%d%d", &AMP;NODE[I].B, &NODE[I].J); to         } +  -Sort (node+1, node+1+n); the  *         intAns =0;intMX =-1; $          for(intI=1; i<=n; ++i)Panax Notoginseng         { -Ans + =node[i].b; themx = max (mx, ans +NODE[I].J); +         } A  theprintf ("Case %d:%d\n", ++cas, MX); +     } -  $     return 0; $ } -  -  the /* - Case 1:8Wuyi Case 2:15 the */

Greedy UVA 11729 Commando War

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.