Submission #67272274


Source Code Expand

#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int read(){int f=0,x=0;char a=getchar();while(!isdigit(a)){if(a=='-')f=1;a=getchar();}while(isdigit(a)){x=x*10+a-'0';a=getchar();}if(f)return -x;return x;}
void solve()
{
    int n;
    cin>>n;
    vector<ll>s(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    sort(s.begin()+2,s.begin()+n);
    // for(int i=1;i<=n;i++)
    // {
    //     cout<<s[i]<<' ';
    // }
    // cout<<'\n';

    ll now=1,ans=1;
    while(111)
    {
        int j=-1;
        if(s[now]*2>=s[n])
        {
            ans++;
            break;
        }
        for(int i=now+1;i<n;i++)
        {
            // cout<<s[i]<<' '<<s[now]<<' '<<j<<'\n'; 
            if(s[i]<=2*s[now])
            {
                if(j==-1)
                {
                    j=i;
                }
                else if(s[j]<s[i])
                {
                    j=i;
                }
            }
            else
            {
                break;
            }
        }
        if(j==-1)
        {
            cout<<"-1\n";
            return;
        }
        ans++;
        now=j;
    }
    cout<<ans<<'\n';
}
int main()
{
    //freopen(in.in,r,stdin);
    //freopen(out.out,w,stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Submission Info

Submission Time
Task C - Giant Domino
User evilwater
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1451 Byte
Status AC
Exec Time 24 ms
Memory 4772 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 03_corner_00.txt, 03_corner_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3468 KiB
01_small_00.txt AC 11 ms 3464 KiB
01_small_01.txt AC 10 ms 3384 KiB
01_small_02.txt AC 8 ms 3412 KiB
01_small_03.txt AC 20 ms 3480 KiB
01_small_04.txt AC 18 ms 3428 KiB
01_small_05.txt AC 18 ms 3480 KiB
01_small_06.txt AC 16 ms 3360 KiB
01_small_07.txt AC 15 ms 3440 KiB
01_small_08.txt AC 15 ms 3408 KiB
02_random_00.txt AC 12 ms 3976 KiB
02_random_01.txt AC 23 ms 4564 KiB
02_random_02.txt AC 24 ms 4532 KiB
02_random_03.txt AC 16 ms 4092 KiB
02_random_04.txt AC 24 ms 4532 KiB
02_random_05.txt AC 22 ms 4624 KiB
02_random_06.txt AC 22 ms 4532 KiB
02_random_07.txt AC 22 ms 4772 KiB
02_random_08.txt AC 20 ms 4276 KiB
02_random_09.txt AC 22 ms 4616 KiB
02_random_10.txt AC 22 ms 4604 KiB
02_random_11.txt AC 18 ms 4388 KiB
02_random_12.txt AC 22 ms 4624 KiB
02_random_13.txt AC 23 ms 4604 KiB
02_random_14.txt AC 20 ms 4388 KiB
02_random_15.txt AC 23 ms 4620 KiB
02_random_16.txt AC 22 ms 4652 KiB
02_random_17.txt AC 20 ms 4392 KiB
02_random_18.txt AC 22 ms 4680 KiB
02_random_19.txt AC 22 ms 4600 KiB
03_corner_00.txt AC 1 ms 3528 KiB
03_corner_01.txt AC 1 ms 3416 KiB