# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234889 | 2020-05-26T07:07:05 Z | mahmoudbadawy | Sirni (COCI17_sirni) | C++17 | 3765 ms | 786436 KB |
#include <bits/stdc++.h> using namespace std; const int N=2e5+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 | Correct | 139 ms | 235384 KB | Output is correct |
2 | Correct | 356 ms | 267768 KB | Output is correct |
3 | Correct | 137 ms | 235640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 135 ms | 235308 KB | Output is correct |
2 | Runtime error | 2467 ms | 786436 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 235384 KB | Output is correct |
2 | Correct | 137 ms | 235256 KB | Output is correct |
3 | Correct | 142 ms | 235524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1617 ms | 250284 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 238072 KB | Output is correct |
2 | Correct | 273 ms | 259448 KB | Output is correct |
3 | Incorrect | 1172 ms | 249936 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1718 ms | 262468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 352 ms | 240600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1776 ms | 254196 KB | Output is correct |
2 | Correct | 3086 ms | 599736 KB | Output is correct |
3 | Correct | 1767 ms | 257136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1778 ms | 258556 KB | Output is correct |
2 | Incorrect | 3765 ms | 762660 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 221 ms | 238568 KB | Output is correct |
2 | Incorrect | 3295 ms | 621712 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |