I was solving this problem and I got TLE CSES - Common Divisors
the only differnet betwen my solution and Usaco one is that the counter in my loop is long long instead of int . why it gives me TLE ?
here is my solution
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
#define vi vector
vi divisors(1000005, 0);
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vi a(n,0);
for(int i =0 ;i < n ;i ++)cin>>a[i];
for (int i = 0; i < n; i++) {
const int up = (int)sqrt(a[i]);
for (int j = 1;j<=up; j++) {
if (a[i] % j == 0) {
if (j != a[i]/j)divisors[j]++;
divisors[a[i] / j]++;
}
}
}
int ans = 0;
for (int i = 0; i < divisors.size(); i++)
if (divisors[i] > 1)
ans = i;
cout<<ans;
}