UVA 11100 The trip, 2007 water Problem One

Source: Internet
Author: User

Title Link: UVA-11100

Test instructions Description: N suitcase, the same shape, different sizes, small size can be placed in the large size of the suitcase. It is now required to keep the smallest number of suitcases in the outermost suitcase while satisfying the fewest number of suitcases in a suitcase. Find any kind of solution that satisfies the requirement.

Algorithm Analysis: First we can determine the minimum number of travel cases CNT: that is, n travel cases in the size of the size of the category (the same size in the same category), the number of the largest category of the number. CNT is then treated as a CNT heap, and the second requirement is that the maximum number of suitcases in this CNT heap be minimized and processed directly with a vector.

After AC suddenly thought, three suitcase size is 2,2,4, then you can put the first two in the last Ah, but the answer is not so. -_-

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <cmath>6#include <algorithm>7#include <vector>8 #defineINF 0x7fffffff9 using namespacestd;Ten Const intmaxn=10000+Ten; One Const intM =1000000+Ten; A  - intN,AN[MAXN]; - intVIS[M],NUM[MAXN]; thevector<int>VEC[MAXN]; -  - intMain () - { +     intok=0; -      while(SCANF ("%d", &n)!=eof &&N) +     { A         if(OK) printf ("\ n"); atok=1; -memset (Vis,0,sizeof(Vis)); -          for(intI=0; i<maxn; i++.) vec[i].clear (); -         intCnt=0, maxsize=0; -          for(intI=1; i<=n; i++.) -         { inscanf"%d",&an[i]); -Vis[an[i]]++; toCnt=Max (Cnt,vis[an[i]]); +Maxsize=Max (maxsize,an[i]); -         } theSort (an+1, an+n+1); *         intC=0; $          for(intI=1; i<=n; i++.)Panax Notoginseng         { - Vec[c].push_back (An[i]); theC= (c+1)%CNT; +         } Aprintf"%d\n", CNT); the          for(intI=0; i<cnt; i++.) +         { -             intk=vec[i].size (); $printf"%d", vec[i][0]); $              for(intj=1; j<k; j + +) printf ("%d", Vec[i][j]); -printf"\ n"); -         } the     } -     return 0;Wuyi}

UVA 11100 The trip, 2007 water Problem One

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.