General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
83518635 Practice:
AbhishekAg
264B - 25 C++17 (GCC 7-32) Wrong answer on test 13 186 ms 1036 KB 2020-06-12 13:01:32 2020-06-12 13:01:32
→ Source
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string imp="Impossible\n";

// const int N=3;
const int N=1e5+5;
ll MOD=1e9+7;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    // cout<<fixed<<setprecision(10);
    int tests=1;
    // cin>>tests;
    while(tests--){
        int n;  cin>>n;
        int MAXN=1e5+5;
        vector<int>a(n);    
        vector<int>fre(1e5+5,0);
        vector<int>dp(1e5+5,0);
        for(int i=0;i<n;i++){    cin>>a[i];
            fre[a[i]]++;
        }
        int ans=1;
        for(int i=0;i<MAXN;i++){
            for(int j=2;j*j<=i;j++){
                if(i%j==0){
                    dp[i]=max(dp[i],dp[i-j]);
                    int can=i/j;
                    if(can!=j)
                        dp[i]=max(dp[i],dp[i-can]);
                }
            }
            if(fre[i])
                dp[i]+=1;
            ans=max(ans,dp[i]);
        }
        cout<<ans;
    }
    return 0;
}

?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details