/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 1ms 532.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    
       ll n;
        cin>>n;
        vector<ll>v(n);
         map<ll,ll>mp;
        ll mx=0;
        for(int i=0;i<n;i++)
        {
            cin>>v[i];
           mp[v[i]]++;
            mx=max(mx,v[i]);
        }
    
        map<ll,ll>sp,dp;
        for(ll i=2;i<=mx;i++)
        {
            for(ll j=i;j<=mx;j+=i)
            {
                if(mp[j]>0)
                {
                     for(int l=0;l<mp[j];l++)
                    {
                        sp[i]++;
                         dp[sp[i]]=max(dp[sp[i]],i);
                    }
        
                   
                    dp[sp[i]]=max(dp[sp[i]],i);
                }
            }
        }
  
        for(int i=1;i<=n;i++)
            cout<<max(1ll,dp[i])<<" ";
        cout<<endl;
        
        
    
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 15:35:03
Judged At
2025-01-02 15:35:03
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB