Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<algorithm>
- #include<vector>
- #include<iomanip>
- using namespace std;
- vector<int> en;
- int n, pre, nex, a=1, b=1, k, tem;
- double pr, t, maxi, mini;
- bool qw;
- void init()
- {
- sort(en.begin(), en.end());
- a=1; b=1; nex=1; pre=n-2; maxi=en[n-1]; mini=en[0]; pr=1-((double)k)/(100.0);
- };
- int main()
- {
- cout.precision(10);
- cin>>n>>k;
- for(int i=1;i<=n;i++)
- {
- cin>>tem;
- en.push_back(tem);
- };
- init();
- while(pre>=nex)
- {
- t=(maxi-(double)en[pre])*((double)a);
- qw=true;
- if(mini+(t/b)*pr>(double)en[nex])
- {
- t=(b*((double)en[nex]-mini))/pr;
- qw=false;
- };
- maxi=maxi-t/((double)a);
- mini=mini+t/((double)b)*pr;
- if(qw)
- {
- a++;
- pre--;
- }
- else
- {
- b++;
- nex++;
- };
- };
- if(mini==maxi)
- {
- cout<<mini;
- cin>>n;
- return 0;
- };
- t=(maxi-mini)/((pr)/((double)b)+(1.0)/((double)a));
- cout<<maxi-t/((double)a)<<endl;
- cin>>n;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement