# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234876 | 2020-05-26T06:40:38 Z | mahmoudbadawy | Sirni (COCI17_sirni) | C++17 | 4468 ms | 263048 KB |
#include <bits/stdc++.h> using namespace std; const int N=1e5+5,M=1e7+7; int n; int arr[N]; vector< pair<int,int> > ed[M]; int uni[N]; int uni_find(int x) { return uni[x]=(uni[x]==x?x:uni_find(uni[x])); } int unio(int x,int y) { x=uni_find(x); y=uni_find(y); if(x==y) return 0; uni[x]=y; return 1; } int main() { scanf("%d",&n); set<int> ss; for(int i=0;i<n;i++) { scanf("%d",&arr[i]); ss.insert(arr[i]); } n=0; for(int i:ss) arr[n++]=i; for(int i=0;i<n;i++) { int s=0; for(int j=arr[i];j<M;j+=arr[i]) { while(s<n && arr[s]<j) s++; if(s<n) ed[arr[s]%j].emplace_back(i,s); } } iota(uni,uni+n,0); long long ans=0; for(int i=0;i<N;i++) { for(auto j:ed[i]) { if(unio(j.first,j.second)) ans+=i; } } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 145 ms | 235360 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 150 ms | 235256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 146 ms | 235384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4468 ms | 250376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 252 ms | 238072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4458 ms | 263048 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 770 ms | 240476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4019 ms | 254188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4054 ms | 258396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 327 ms | 238456 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |