BZOJ4004 [JLOI2015] Equipment purchase

Source: Internet
Author: User

First, according to the price from small to large sort, and then one by one to see if you can add in ...

Naked Quasi-array I'm going to qaq.

But to understand, you can think like this, is similar to the Gaussian elimination of the steps ... But the elimination of the elements is in order.

1 /**************************************************************2 problem:40043 User:rausen4 language:c++5 result:accepted6 time:812 Ms7 memory:2840 KB8 ****************************************************************/9  Ten#include <cstdio> One#include <cmath> A#include <algorithm> -   - using namespacestd; thetypedefDoubleLF; - Const intN =505; -   -InlineintRead () { +     Static intx; -     Static Charch; +x =0, ch =GetChar (); A      while(Ch <'0'||'9'<ch) atCH =GetChar (); -      while('0'<= CH && Ch <='9') { -x = x *Ten+ CH-'0'; -CH =GetChar (); -     } -     returnx; in } -   toTemplate <classT>intsgn (T x) { +     StaticT EPS = 1e-5; -     if(Fabs (x) < EPS)return 0; the     returnEPS >0?1: -1; * } $  Panax Notoginseng structData { -     intC; the LF V[n]; +       AInline lf&operator[] (inti) { the         returnV[i]; +     } -       $Inlinevoid Get(intm) { $         Static inti; -          for(i =1; I <= m; ++i) V[i] =read (); -     } the       -InlineBOOL operator< (ConstData &p)Const {Wuyi         returnC <p.c; the     } - } A[n]; Wu   - intN, M; About intW[n], ans1, ans2; $   - intMain () { -     intI, J, K; - LF tmp; An = Read (), M =read (); +      for(i =1; I <= N; ++i) A[i].Get(m); the      for(i =1; I <= N; ++i) a[i].c =read (); -Sort (A +1, A + n +1); $       the      for(i =1; I <= N; ++i) the          for(j =1; J <= M; ++J)if(SGN (a[i][j]) = =1) { the             if(W[j]) { theTMP = A[i][j]/A[w[j]][j]; -                  for(k = j; k <= m; ++k) a[i][k]-= tmp *A[w[j]][k]; in}Else { theW[J] =i; the++ANS1, Ans2 + =a[i].c; About                  Break; the             } the         } theprintf"%d%d\n", ans1, ans2); +     return 0; -}
View Code

BZOJ4004 [JLOI2015] Equipment purchase

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.