/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 2ms 764.0 KiB
#4 Wrong Answer 2ms 324.0 KiB
#5 Wrong Answer 2ms 324.0 KiB
#6 Wrong Answer 2ms 320.0 KiB
#7 Wrong Answer 2ms 324.0 KiB
#8 Wrong Answer 3ms 540.0 KiB
#9 Wrong Answer 3ms 320.0 KiB
#10 Wrong Answer 5ms 532.0 KiB
#11 Accepted 15ms 320.0 KiB
#12 Wrong Answer 15ms 324.0 KiB
#13 Wrong Answer 8ms 564.0 KiB
#14 Wrong Answer 8ms 532.0 KiB
#15 Wrong Answer 8ms 532.0 KiB
#16 Wrong Answer 9ms 512.0 KiB
#17 Wrong Answer 8ms 324.0 KiB
#18 Wrong Answer 9ms 532.0 KiB
#19 Wrong Answer 8ms 532.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;


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


            }

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

            }

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

        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 16:46:36
Judged At
2024-10-03 13:26:01
Judged By
Score
11
Total Time
15ms
Peak Memory
764.0 KiB