Submission #7286200


Source Code Expand

Copy
    //For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,k,pos;
            vector<pll> v,v2;
            ll a,b,x,y,ans=0,ct,maxi;
            cin>>n;
            for(i=1;i<=n;++i)
            {
                cin>>a>>b;
                v.pb({a,b});
            }
            for(i=-1;i<=1;i=i+2)
            {
                for(j=-1;j<=1;j=j+2)
                {
                    x=0,y=0;
                    v2.clear();
                    for(auto it:v)
                    {
                        if(it.f*i>=0 && it.s*j>=0)
                        {
                            x=x+it.f;
                            y=y+it.s;
                        }
                        else
                            v2.pb({it.f,it.s});
                    }
                    while(v2.size()>0)
                    {
                        maxi=-1;
                        pos=-1;
                        for(k=0;k<v2.size();++k)
                        {
                            if((x+v2[k].f)*(x+v2[k].f) + (y+v2[k].s)*(y+v2[k].s) - (x*x+y*y) > maxi)
                            {
                                maxi=(x+v2[k].f)*(x+v2[k].f) + (y+v2[k].s)*(y+v2[k].s) - (x*x+y*y);
                                pos=k;
                            }
                        }
                        if(maxi<0)
                            break;
                        //cout<<v2.size()<<" "<<pos<<endl;
                        x=x+v2[pos].f;
                        y=y+v2[pos].s;
                        v2.erase(v2.begin()+pos);
                    }
                    //cout<<x<<"..."<<y<<endl;
                    ans=max(ans,x*x+y*y);
                }
            }
            //cout<<ans<<endl;
            ld l=0.0,r=2e8,mid;
            for(i=0;i<=200;++i)
            {
                mid=(l+r)/2;
                if(mid*mid>ans)
                    r=mid;
                else
                    l=mid;
            }
            printf("%.15Lf\n",mid);
        }
        return 0;
    }

Submission Info

Submission Time
Task F - Engines
User sdssudhu
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3046 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 7
AC × 36
WA × 5
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt, 01-random-very-small-01.txt, 01-random-very-small-02.txt, 01-random-very-small-03.txt, 02-random-small-01.txt, 02-random-small-02.txt, 02-random-small-03.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 04-zero-01.txt, 05-same-01.txt, 05-same-02.txt, 06-linear-01.txt, 06-linear-02.txt, 06-linear-03.txt, 07-linear-positive-01.txt, 07-linear-positive-02.txt, 07-linear-positive-03.txt, 08-90-degree-01.txt, 08-90-degree-02.txt, 09-180-degree-01.txt, 09-180-degree-02.txt, 10-sandglass-01.txt, 10-sandglass-02.txt, 11-circle-01.txt, 11-circle-02.txt, 11-circle-03.txt, 11-circle-04.txt, 11-circle-05.txt, 12-square-01.txt, 12-square-02.txt, 12-square-03.txt, 13-corner-01.txt, 13-corner-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 256 KB
00-sample-02.txt AC 1 ms 256 KB
00-sample-03.txt AC 1 ms 256 KB
00-sample-04.txt AC 1 ms 256 KB
00-sample-05.txt AC 1 ms 256 KB
00-sample-06.txt AC 1 ms 256 KB
00-sample-07.txt AC 1 ms 256 KB
01-random-very-small-01.txt AC 1 ms 256 KB
01-random-very-small-02.txt AC 1 ms 256 KB
01-random-very-small-03.txt AC 1 ms 256 KB
02-random-small-01.txt AC 1 ms 256 KB
02-random-small-02.txt AC 1 ms 256 KB
02-random-small-03.txt WA 1 ms 256 KB
03-random-01.txt AC 1 ms 256 KB
03-random-02.txt AC 1 ms 256 KB
03-random-03.txt AC 1 ms 256 KB
04-zero-01.txt AC 1 ms 256 KB
05-same-01.txt AC 1 ms 256 KB
05-same-02.txt AC 1 ms 256 KB
06-linear-01.txt AC 1 ms 256 KB
06-linear-02.txt AC 1 ms 256 KB
06-linear-03.txt AC 1 ms 256 KB
07-linear-positive-01.txt AC 1 ms 256 KB
07-linear-positive-02.txt AC 1 ms 256 KB
07-linear-positive-03.txt AC 1 ms 256 KB
08-90-degree-01.txt AC 1 ms 256 KB
08-90-degree-02.txt AC 1 ms 256 KB
09-180-degree-01.txt AC 1 ms 256 KB
09-180-degree-02.txt AC 1 ms 256 KB
10-sandglass-01.txt AC 1 ms 256 KB
10-sandglass-02.txt AC 1 ms 256 KB
11-circle-01.txt AC 1 ms 256 KB
11-circle-02.txt AC 1 ms 256 KB
11-circle-03.txt AC 1 ms 256 KB
11-circle-04.txt AC 1 ms 256 KB
11-circle-05.txt WA 1 ms 256 KB
12-square-01.txt WA 1 ms 256 KB
12-square-02.txt WA 1 ms 256 KB
12-square-03.txt WA 1 ms 256 KB
13-corner-01.txt AC 1 ms 256 KB
13-corner-02.txt AC 1 ms 256 KB