# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
890042 |
2023-12-20T12:00:24 Z |
codefox |
Sirni (COCI17_sirni) |
C++14 |
|
3047 ms |
786432 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define int ll
#define f first
#define s second
vector<int> rep;
int finde(int i)
{
if (i != rep[i]) rep[i] = finde(rep[i]);
return rep[i];
}
int32_t main()
{
int n;
cin >> n;
vector<int> nums;
vector<int> mult(1e7+1, -1);
vector<bool> vis(1e7+1, 0);
for(int i = 0; i < n; i++)
{
int a;
cin >> a;
if (vis[a]) continue;
vis[a] = true;
nums.push_back(a);
}
sort(nums.begin(), nums.end());
ll sol = 0;
n = nums.size();
int curr = 0;
int val = -1;
for (int i = 0; i < n; i++)
{
int ele = nums[i];
while (curr < ele)
{
mult[curr] = val;
curr++;
}
val = i;
}
while (curr <= 1e7)
{
mult[curr] = val;
curr++;
}
vector<vector<pii>> dist(1e7);
rep = vector<int>(n);
iota(rep.begin(), rep.end(), 0);
for (int i = 0; i < n; i++)
{
for (int j = nums[i]; j <= 1e7; j+=nums[i])
{
int best = mult[j];
if (best != -1) dist[j-nums[best]].push_back({i, best});
}
}
int c = 0;
for (int i = 0; i < 1e7; i++)
{
for (pii ele:dist[i])
{
if (finde(ele.f) !=finde(ele.s))
{
sol+=i;
rep[finde(ele.f)]=finde(ele.s);
c++;
}
}
if (c==n-1) break;
}
cout << sol;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
137 ms |
314960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1584 ms |
526880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
92 ms |
314948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2654 ms |
582364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
494 ms |
366800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3047 ms |
786432 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2979 ms |
786432 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
344156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
196 ms |
353220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
319648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |