# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
991065 |
2024-06-01T08:12:51 Z |
BF001 |
Sirni (COCI17_sirni) |
C++17 |
|
672 ms |
786432 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100005
#define se second
#define fi first
int n, par[N], res = 0;
vector<int> p;
struct ii
{
int u, v, w;
bool operator < (ii o){
return w < o.w;
}
};
int find(int u){
if (u == par[u]) return u;
return par[u] = find(par[u]);
}
void unin(int u, int v, int w){
u = find(u);
v = find(v);
if (u == v) return;
par[u] = v;
res += w;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++){
int val;
cin >> val;
p.push_back(val);
}
sort(p.begin(), p.end());
p.resize(unique(p.begin(), p.end()) - p.begin());
int ma = p.back();
vector<int> near(ma + 1, -1);
vector<vector<pair<int, int>>> eg(ma + 1);
for (int i = 0; i < (int) p.size(); i++){
par[i] = i;
near[p[i]] = i;
}
for (int i = ma - 1; i >= 0; i--){
if (near[i] == -1) near[i] = near[i + 1];
}
for (int i = 0; i < (int) p.size(); i++){
eg[(p[i + 1] % p[i])].push_back({i, i + 1});
for (int j = 2 * p[i]; j <= ma; j += p[i]){
int pos = near[j];
eg[(p[pos] % p[i])].push_back({i, pos});
}
}
for (int i = 0; i <= ma; i++){
for (auto x : eg[i]){
unin(x.fi, x.se, i);
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
313424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Runtime error |
672 ms |
786432 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
313428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
53204 KB |
Output is correct |
2 |
Correct |
125 ms |
123572 KB |
Output is correct |
3 |
Correct |
71 ms |
78524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
35676 KB |
Output is correct |
2 |
Correct |
74 ms |
77264 KB |
Output is correct |
3 |
Correct |
47 ms |
38136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
79876 KB |
Output is correct |
2 |
Correct |
142 ms |
150936 KB |
Output is correct |
3 |
Correct |
64 ms |
74940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
14028 KB |
Output is correct |
2 |
Correct |
148 ms |
148300 KB |
Output is correct |
3 |
Correct |
65 ms |
80492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
341196 KB |
Output is correct |
2 |
Runtime error |
577 ms |
786432 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
351432 KB |
Output is correct |
2 |
Runtime error |
587 ms |
786432 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
318676 KB |
Output is correct |
2 |
Runtime error |
662 ms |
786432 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |