Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long double hi=1e14+5;
- long double lo=0;
- int n,area,i,soma,v[150000];
- while (1)
- {
- hi=1e14+5;
- lo=0-1e-9;
- soma=0;
- scanf("%d %d",&n,&area);
- if (n==0 && area==0)break;
- for (i=0; i<n; i++)
- {
- scanf("%d",&v[i]);
- soma+=v[i];
- }
- if (soma==area)
- printf(":D\n");
- else
- {
- if (soma<area)
- printf("-.-\n");
- else
- {
- long double md;
- while (1)
- {
- md=(hi+lo)/2;
- for (int i=0;i<n;i++)
- {
- if (md < v[i])
- v[i]-=md;
- }
- soma=0;
- for (int i=0;i<n;i++)
- {
- soma+=v[i];
- }
- if (soma - area > 1e-4 )
- lo=md;
- else if (area-soma > 1e-4)
- hi=md;
- else if (area - soma <=1e-4 || soma - area<= 1e-4 )
- break;
- }
- cout << lo << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement