/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 536.0 KiB
#2 Wrong Answer 29ms 532.0 KiB
#3 Wrong Answer 311ms 540.0 KiB
#4 Wrong Answer 292ms 540.0 KiB
#5 Wrong Answer 317ms 532.0 KiB
#6 Wrong Answer 307ms 324.0 KiB
#7 Wrong Answer 325ms 324.0 KiB
#8 Wrong Answer 557ms 536.0 KiB
#9 Wrong Answer 847ms 544.0 KiB
#10 Time Exceeded ≥1093ms ≥552.0 KiB
#11 Time Exceeded ≥1096ms ≥544.0 KiB
#12 Time Exceeded ≥1080ms ≥540.0 KiB
#13 Time Exceeded ≥1091ms ≥560.0 KiB
#14 Time Exceeded ≥1092ms ≥560.0 KiB
#15 Time Exceeded ≥1086ms ≥548.0 KiB
#16 Time Exceeded ≥1093ms ≥556.0 KiB
#17 Time Exceeded ≥1095ms ≥764.0 KiB
#18 Time Exceeded ≥1094ms ≥548.0 KiB
#19 Time Exceeded ≥1096ms ≥560.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      long long n;
      cin>>n;
      vector<long long>v(n);
      for(int i=0;i<n;i++)
      {
          cin>>v[i];
      }

      sort(v.begin(),v.end());
      reverse(v.begin(),v.end());

      long long odd=n/2;

      if(n%2!=0)
        odd++;

        long long even=n/2;

        long long anse=1;
        long long anso=1;


        long long p=0;




        for(int i=1;i<=104;i++)
        {
            for(int j=1;j<=104;j++)
            {
                map<long long,long long>mapp;
                long long cnt1=0;
                for(int k=0;k<n;k++)
                {
                    if(v[k]%i==0)
                        cnt1++;

                }

                if(cnt1>=odd)
                {
                    long long y1=0;
                    for(int k=0;k<n;k++)
                    {
                        if(y1>=odd)
                            break;
                        if(v[k]%i==0&&v[k]%j!=0)
                        {
                            y1++;
                            mapp[k]++;

                        }
                    }

                    for(int k=0;k<n;k++)
                    {
                        if(y1>=odd)
                            break;
                        if(v[k]%i==0)
                        {
                            y1++;
                            mapp[k]++;

                        }
                    }
                }

                long long cnt2=0;

                for(int k=0;k<n;k++)
                {
                    if(mapp[k]==0&&v[k]%j==0)
                        cnt2++;
                }


                if(cnt2>=even&&cnt1>=odd)
                {
                    long long bye=i+j;
                    //cout<<i<<" "<<j<<endl;

                    p=max(bye,p);

                }


            }
        }

        cout<<p<<endl;


        //for(int i=105;i>=1;i--)
      /*  {
            long long cnt=0;
            for(int j=0;j<n;j++)
            {
                if(v[j]%i==0&&mapp[v[j]]==0)
                cnt++;


            }

            if(cnt>=odd&&i>anso)
            {
                //anso+=i;
               // anso=max(anso,i);
               anso=i;
                cnt-=odd;

                long long u1=0;

                for(int j=0;j<n;j++)
                {
                    if(u1>=odd)
                        break;

                }

            }

            if(cnt>=even&&i>anse)
            {
                anse=i;
                cnt-=even;
            }
        }

       // cout<<anse<<" "<<anso<<endl;

        cout<<anse+anso<<endl;

       /* long long maxxo=1;

      for(int i=0;i<n;i++)
      {
          long long gcdd=v[i];

          long long check=0;

          for(int j=0;j<n;j++)
          {
              if(check>=odd)
                break;
              if(i==j)
                continue;

                long long temp=__gcd(v[j],gcdd);
                if(temp!=1)
                {
                    check++;
                    gcdd=temp;

                }
          }

          if(check>=odd)
          {
              maxxo=max(maxxo,gcdd);
          }
      }



      long long maxxe=1;

      for(int i=0;i<n;i++)
      {
          long long gcdd=v[i];

          long long check=0;

          for(int j=0;j<n;j++)
          {
              if(check>=even)
                break;
              if(i==j)
                continue;

                long long temp=__gcd(v[j],gcdd);
                if(temp!=1)
                {
                    check++;
                    gcdd=temp;

                }
          }

          if(check>=even)
          {
              maxxe=max(maxxe,gcdd);
          }
      }


      //cout<<maxxe<<endl;


      cout<<maxxo+maxxe<<endl;*/






    }
}

Information

Submit By
Type
Submission
Problem
P1076 Even Odd GCD (Easy Version)
Contest
Bangladesh 2.0
Language
C++11 (G++ 13.2.0)
Submit At
2024-08-16 17:23:51
Judged At
2024-10-03 13:22:09
Judged By
Score
1
Total Time
≥1096ms
Peak Memory
≥764.0 KiB