# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701011 |
2023-02-19T17:40:08 Z |
amin |
Sirni (COCI17_sirni) |
C++14 |
|
1030 ms |
755296 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
ll nex[10000002];
ll sz[10000002],vis[10000002];
ll p[20000000];
ll ans=0;
int par(int x)
{
if(p[x]==x)
return x;
p[x]=par(p[x]);
return p[x];
}
void un(int x,int y,ll cost)
{
x=par(x);
y=par(y);
if(x==y)
{
return ;
}
ans+=cost;
if(sz[x]<sz[y])
{
swap(x,y);
}
sz[x]+=sz[y];
sz[y]=0;
p[y]=x;
}
int main()
{
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
p[a[i]]=a[i];
sz[a[i]]=1;
nex[a[i]]=a[i];
}
for(int i=10000000;i>=0;i--)
{
if(nex[i]==i)
{
continue;
}
nex[i]=nex[i+1];
}
vector<pair<ll,ll> >v[10000000];
for(int i=1;i<=1e7;i++)
{
if(nex[i]==i&&vis[i]==0)
{
vis[i]=1;
for(int y=i;y<=1e7;y+=i)
{
vis[y]=1;
// if(nex[y]!=0)
if(nex[y]==y)
{
v[0].push_back({i,y});
}
v[nex[y+1]%i].push_back({i,nex[y+1]});
}
}
}
for(ll i=0;i<1e7;i++)
{
for(auto y:v[i])
{
un(y.first,y.second,i);
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
219 ms |
339916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
451 ms |
523272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
226 ms |
341732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
604 ms |
548944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
355 ms |
442684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
905 ms |
691040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
728 ms |
661612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
418 ms |
572684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
430 ms |
582332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
299 ms |
497084 KB |
Output is correct |
2 |
Incorrect |
1030 ms |
755296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |