# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1042607 |
2024-08-03T08:28:11 Z |
Abito |
Sirni (COCI17_sirni) |
C++17 |
|
283 ms |
79964 KB |
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=1e6+5;
int a[N],n,par[N],sz[N];
int getpar(int x){
if (x==par[x]) return x;
return par[x]=getpar(par[x]);
}
void link(int x,int y){
x=getpar(x);
y=getpar(y);
if (x==y) return;
if (sz[x]>sz[y]) swap(x,y);
sz[y]+=sz[x];
par[x]=y;
return;
}
vector<int> d[N];
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i],par[i]=i,sz[i]=1;
sort(a+1,a+1+n);
int mx=0,k=0,ans=0;
vector<vector<int>> v;
for (int i=1;i<=n;i++){
while (k<=a[i]){
k++;
if (d[k].size()) mx=k;
}
for (auto u:d[mx]) v.pb({a[i]%a[u],i,u});
for (int j=a[i];j<N;j+=a[i]) d[j].pb(i);
}
sort(v.begin(),v.end());
for (auto u:v){
int x=getpar(u[1]),y=getpar(u[2]);
if (x==y) continue;
link(x,y);
ans+=u[0];
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
21 ms |
54868 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
38736 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
50892 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
57592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
31124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
283 ms |
79964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
158 ms |
57660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
60812 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
66704 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
60500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |