A:
In the sign in question in Guilin a few days ago, I became a volunteer. A team showed me that it was stupid after a minute. Then I directly copied the classic. In a minute, it was two wins in three games and three wins in five games. Just output 2n-1
B:
Meaning:
Give you an array and a number c. you are required to divide the array into several consecutive substrings. Delete the minimum number of [k/c] (k is the length of the string) in each string. Ask how to maximize the sum of the remaining numbers
Idea:
First of all, the remaining numbers must be deleted as many as possible, so the length of each interval we divide should be a multiple of C as far as possible. Then we consider that when the interval length is 2c, when the interval length is 2c, the sum of the two minimum values selected from it must be less than or equal to the sum of the minimum values I split into two intervals with length C from the middle, Reason: assuming that the minimum value of the interval with a length of 2C is on the left, I will be divided into left and right parts, and a number larger than the previous two minimum values will come out on the right. Assuming that the minimum value is on both sides of the branch, I will split the same. Therefore, we only need to consider dividing the interval into intervals with length C or length 1 every time (why is the length 1: because the remaining intervals must be those with length less than C and will not be deleted, the conclusion is very concise when the length is one). The rest is simple. We maintain the minimum value (monotonic queue) of each interval with length C, Then select the non conflicting and largest intervals (dp)
Zhu dad told me this question before, but I didn't think about it until Zhu dad came over and told me his ideas. I didn't think about it. I thought e was relatively simple, so I went to do E. Woo woo
#include <bits/stdc++.h> using namespace std; #define ll long long ll x[100001]; ll mn[100001]; ll dp[100001]; int main(){ ll n,m; cin>>n>>m; ll all=0; for(int i=0;i<n;i++){ cin>>x[i]; all+=x[i]; } deque<ll>q; //There are several bursts of monotonous queue (shit, fw) in front. The subscript must be saved here, and the value cannot be saved. Otherwise, this value will appear. Obviously, it is not in the interval, but it is also calculated as the minimum value for(int i=0;i<n;i++){ while(!q.empty()&&x[q.back()]>x[i]){ q.pop_back(); } q.push_back(i); if(q.front()<=i-m){ q.pop_front(); } mn[i]=x[q.front()]; } for(int i=0;i<m;i++){ dp[i]=0; } dp[m-1]=mn[m-1]; ll ans=dp[m-1]; for(int i=m;i<n;i++){ //No one can't think of this transfer equation (, although I didn't think of doing it with dp at first) dp[i]=max(dp[i-1],mn[i]+dp[i-m]); ans=max(ans,dp[i]); } cout<<all-ans<<endl; return 0; }
C:
60d96203192132ddf55f8ead09e2f322 (ppsucxtt.cn)
The questions on UVA were OK, and the website collapsed
Meaning:
Given the left and right boundaries, find the total number of zeros of all numbers in the interval
Idea:
The first example on the oiwiki, xswl didn't learn at all. I thought it was a mathematical problem and thought about it for a long time. I just opened dp in recent weeks. I'll make it up when I learned it.
D:
Big big big simulation, the title thief is long, don't want to see, so I didn't write it
Given some formulas for defining variables, calculate the memory occupied
There is a disgusting place. The title says round up to. I found out that it is rounded, but I wrote it by rounding up (because the example is rounding up), and then passed
#include <bits/stdc++.h> using namespace std; #define ll long long int fun(string a){ int pos1=a.find('['); int pos2=a.find(']'); if(pos1==string::npos||pos2==string::npos){ return 1; }else{ string tem=a.substr(pos1+1,pos2-2); int ans=atoi(tem.c_str()); return ans; } } int main(){ int t; cin>>t; ll ca=1; while(t--){ int n; cin>>n; ll ans=0; for(int i=0;i<n;i++){ string a; cin>>a; string b; cin>>b; int num=fun(b); if(a=="int"){ ans+=num*4; }else if(a=="char"){ ans+=num*1; }else if(a=="bool"){ ans+=num*1; }else if(a=="long"){ string c; cin>>c; num=fun(c); if(b=="long"){ ans+=num*8; }else if(b=="double"){ ans+=num*16; } }else if(a=="__int128"){ ans+=num*16; }else if(a=="float"){ ans+=num*4; }else if(a=="double"){ ans+=num*8; } } printf("Case #%lld: ",ca++); if(ans%1024!=0){ ans+=1024; } cout<<ans/1024<<endl; } return 0; }
Rubbish wrong topic, like to mention it again wa.