CSP-S Analog 99

Number of examinations is about, oh Pobai

 

 

  T1 Tao Tao picking apples

    Segment tree maintenance monotonous stack? Seems.

    After playing two Fenwick tree + Chairman of the tree, wa50, open test on the test found an array of small kuku ~

  T2 happy Jinming

    greedy

    Pretreatment of raw material The minimum price per month $ c_i = min (c_ {i-1} + R_ {i-1}, c_i) $

    All can be produced even computer prices (+ cost required for storing money) with a large number of roots into the stack (sorted by price), the $ i-1 $ I $ to the second month months only $ E $ storage [i-1] $ computer, pop off so expensive computers, such that the storage amount does not exceed $ e [i-1] $, then stored into the whole computer rootlets stack (also by price row), taken low-cost computers to meet customer demand, then remove the computer to computer is the real actual production, plus contributions

  If the storage amount is less than customer demand, output -1

  T3 stupid monkey

    I hit the Qingshui half, a mid value to the right as A plus B, according to the sum sorting, before taking the n + 1, it is determined as sumA greater than the sum of the remaining A and B of the remaining less than sumB and, reducing the weight of mid, mid otherwise increase

For sumA less than the sum of the remaining A and B where the remaining less than the sum of sumB, -1 should be output. I think so, but the solution to a problem is this:

    

 

   And there will be no problem explain the situation -1

  It is so proven:

  

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/heoitys/p/11790538.html