# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863469 |
2023-10-20T12:04:59 Z |
blacktulip |
Sirni (COCI17_sirni) |
C++17 |
|
693 ms |
148084 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t,fa[li],vis[10000005],mx[10000005],ind[10000005];
long long cev;
string s;
vector<pair<int,pair<int,int>>> v;
set<pair<int,int>> st;
inline int dsu(int x){
if(x==fa[x])return x;
return fa[x]=dsu(fa[x]);
}
int main(void){
//~ fio();
cin>>n;
FOR{
fa[i]=i;
cin>>a[i];
mx[a[i]]=a[i];
}
for(int i=10000000-1;i>=1;i--){
if(!mx[i])mx[i]=mx[i+1];
}
sort(a+1,a+n+1);
FOR{
if(!ind[a[i]])ind[a[i]]=i;
}
FOR{
if(a[i]==a[i-1]){
v.pb({0,{i-1,i}});
continue;
}
if(vis[a[i]]){v.pb({0,{i,vis[a[i]]}});}
if(mx[a[i]+1])v.pb({mx[a[i]+1],{i,ind[mx[a[i]+1]]}});
for(int j=a[i]*2;j<=10000000;j+=a[i]){
//~ if(vis[j])continue;
vis[j]=i;
if(mx[j])v.pb({mx[j]-j,{i,ind[mx[j]]}});
}
}
sort(v.begin(),v.end());
for(auto go:v){
int co=go.fi;
int x=go.se.fi;
int y=go.se.se;
if(dsu(x)==dsu(y))continue;
fa[dsu(x)]=dsu(y);
cev+=co;
}
cout<<cev<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
86108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
84684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
86536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
334 ms |
114904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
84 ms |
91592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
693 ms |
138604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
301 ms |
92460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
283 ms |
148084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
372 ms |
147636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
120264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |