# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234888 | 2020-05-26T07:06:17 Z | mahmoudbadawy | Sirni (COCI17_sirni) | C++17 | 1766 ms | 262228 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=i+1; assert(arr[i]); for(int j=arr[i];j<arr[n-1];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 | 135 ms | 235384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 154 ms | 235360 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 137 ms | 235384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1634 ms | 250452 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 181 ms | 237944 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1723 ms | 262228 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 357 ms | 240728 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1766 ms | 254136 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1758 ms | 258624 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 217 ms | 238456 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |