Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main() {
- int n;
- cin >> n;
- int a[n];
- int b[n];
- for(int i=0;i<n;i++) {
- cin >> a[i];
- b[i]=a[i];
- }
- sort(a,a+n);
- sort(b,b+n);
- int min_index = 0;
- int maximum = a[n-1];
- int minimum = a[min_index];
- bool ans=false;
- int count = 0;
- // cout << maximum << b[0];
- // cout << minimum << ' ' << a[n-1];
- while(!ans) {
- sort(a,a+n);
- if(2*minimum >= a[n-1]) {
- ans=true;
- break;
- }
- else{
- a[n-1]=0;
- sort(a,a+n);
- }
- count++;
- }
- int count2=0;
- ans=false;
- while(!ans) {
- sort(b,b+n);
- if(2*minimum >= b[n-1]) {
- ans=true;
- break;
- }
- else{
- b[0]=maximum;
- sort(b,b+n);
- minimum=b[0];
- }
- count2++;
- }
- cout << min(count2,count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement