# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
636441 |
2022-08-29T09:40:03 Z |
dozer |
Sirni (COCI17_sirni) |
C++14 |
|
5000 ms |
244556 KB |
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int , int>
#define st first
#define nd second
#define N 10000005
int root[N], sz[N], arr[N];
vector<int> ind[N];
set<int> roots;
int find(int node)
{
if (root[node] == node) return node;
return root[node] = find(root[node]);
}
void uni(int a, int b)
{
a = find(a), b = find(b);
if (a == b) return;
if (sz[a] > sz[b]) swap(a, b);
roots.erase(a);
root[a] = b;
sz[b] += sz[a];
}
int32_t main()
{
fastio();
int n;
cin>>n;
int maks = 0;
vector<int> v;
for (int i = 1; i <= n; i++)
{
cin>>arr[i];
if (ind[arr[i]].size() == 0) v.pb(arr[i]);
ind[arr[i]].pb(i);
root[i] = i;
sz[i] = 1;
roots.insert(i);
maks = max(maks, arr[i]);
}
int rem = 0;
int ans = 0;
while(roots.size() > 1)
{
for (auto curr : v)
{
int i = ind[curr].front();
for (int j = rem; j <= maks; j += curr)
{
for (auto k : ind[j])
{
if (find(i) != find(k)) uni(i, k), ans += rem;
}
}
}
rem++;
}
cout<<ans<<endl;
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1004 ms |
235188 KB |
Output is correct |
2 |
Correct |
1467 ms |
235248 KB |
Output is correct |
3 |
Correct |
717 ms |
235256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
235248 KB |
Output is correct |
2 |
Correct |
983 ms |
235248 KB |
Output is correct |
3 |
Correct |
318 ms |
235260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
935 ms |
235168 KB |
Output is correct |
2 |
Correct |
398 ms |
235216 KB |
Output is correct |
3 |
Correct |
669 ms |
235256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
512 ms |
244352 KB |
Output is correct |
2 |
Correct |
716 ms |
243728 KB |
Output is correct |
3 |
Correct |
279 ms |
243752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
236500 KB |
Output is correct |
2 |
Correct |
561 ms |
241916 KB |
Output is correct |
3 |
Correct |
409 ms |
243976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
731 ms |
244396 KB |
Output is correct |
2 |
Correct |
474 ms |
244224 KB |
Output is correct |
3 |
Correct |
308 ms |
244320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
238640 KB |
Output is correct |
2 |
Correct |
622 ms |
243532 KB |
Output is correct |
3 |
Correct |
279 ms |
243976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2196 ms |
244548 KB |
Output is correct |
2 |
Correct |
1390 ms |
244520 KB |
Output is correct |
3 |
Correct |
2003 ms |
244516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
702 ms |
244556 KB |
Output is correct |
2 |
Correct |
3489 ms |
243948 KB |
Output is correct |
3 |
Correct |
356 ms |
244384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2160 ms |
237052 KB |
Output is correct |
2 |
Execution timed out |
5061 ms |
243516 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |