Cut the Sticks

Source: Internet
Author: User

1 defMain ():2n =Int (raw_input ())3arr =map (int, raw_input (). Strip (). Split ())4 5      forIinchrange (n):6Cutnum =07MinValue =min (arr)8          for_inchrange (n):9             if0 < Arr[_] < 1001:TenArr[_]-=MinValue OneCutnum + = 1 A             ifArr[_] <= 0:#to make an inappropriate value, a stripping cycle -Arr[_] = 1001 -         ifCutnum! = 0:#two-layer loops are rich out, so only output is not 0, a dynamic adjustment of coding the             PrintCutnum -      -Main ()

Learn

Try

Operations such as pop

A new way of thinking

1n =Int (raw_input (). Strip ())2sticks = [Int (i) forIinchraw_input (). Strip (). Split ( )3 Sticks.sort ()4NewItem =Sticks[0]5Count =len (sticks)6 PrintCount7Count-= 18  forIinchRange (1, Len (sticks)):9     ifSticks[i]! =NewItem:TenNewItem =Sticks[i] One         PrintCount ACount-= 1

Learn

The order is not important, it is possible to sort it out first.

Cut the Sticks

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.