Final Exam (positive solutions: one-third UNIMODAL me: violence over water)

Long time no water too complex a problem!

Today lsc finally just had three questions of the exam questions runoff miscellaneous!

Final Exam

 

First, a look or a look mb (This is a normal phenomenon, after all, I am not like some of the great god glance a positive solution) and then I was decadent label, know-thirds unimodal function, but that she is too weak, and so third of the runoff will not use the title, you can only use violence to do;

We know that last degree of nausea (the unpleasant question of where) is the only and final results in about a day, so violent enumerate the day the results, and then use the prefix can do enumeration 1 million can be the answer, in fact, min is to take it!

If A <B, then obviously better to use the first method, but we O (1) operator

Then it is to maintain the prefix and the number of days can be postponed and, finally sentenced on the line, pay attention to long long and res> ans to come out;

Specific look at the code:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 const int N=100005;
 5 ll ans=1ll<<62,A,B,C,s1,s2,s3,s4,res=0;
 6 int n,m,t[N],b[N];
 7 int main()
 8 {
 9     scanf("%lld%lld%lld%d%d",&A,&B,&C,&n,&m);
10     for(int i=1,x;i<=n;i++)scanf("%d", & X), T [X] ++ ;
 . 11      for ( int I = . 1 , X; I <= m; I ++) Scanf ( " % D " , & X), B [X] ++, S3 + = X;
 12 is      for ( int T = . 1 ; T <= 100000 ; T ++ )
 13 is      {
 14          RES = S1 + C *; // nausea degree! 
15          S1 = T + [T]; // to this day the desired number of scores! In fact, we are already waiting for the number to reach the pole! 
16          IF (RES> = ANS) BREAK ;
 . 17          S4 + S2 =; // number of days less than i can retire days late! 
18 is          S3 - = (m-S2); //Yet the number of points! 
. 19          S2 = B + [T]; // the number of points in the previous day! 
20 is          LL R & lt;
 21 is          IF (B <= A) = S3 * B R & lt; // clear that using the second method Haoshi 
22 is          the else  IF (S3 <S4 =) * S3 A = R & lt; // only points out not is less than a minute can be used to engage in a 
23 is          the else R & lt S4 * = a + (S3-S4) * B; // otherwise engage on mixing! 
24          ANS = min (ANS, RES + R & lt);
 25      }
 26 is      the printf ( " % LLD \ n- " , ANS);
 27 }
View Code

 

Guess you like

Origin www.cnblogs.com/hzoi-lsc/p/11465130.html