# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
393426 |
2021-04-23T12:11:57 Z |
ngpin04 |
Sirni (COCI17_sirni) |
C++14 |
|
321 ms |
88068 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N = 1e7 + 5;
int a[N];
int p[N];
int val[N];
int n;
bool mini(int &a, int b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a + 1, a + n + 1);
n = unique(a + 1, a + n + 1) - (a + 1);
for (int i = 1; i <= n; i++) {
p[a[i]] = a[i];
val[a[i]] = 1e9;
}
int mx = a[n];
for (int i = mx - 1; i >= 1; i--)
if (!p[i])
p[i] = p[i + 1];
val[a[1]] = 0;
priority_queue <pair <int, int>> heap;
heap.push(mp(0, a[1]));
long long ans = 0;
while (heap.size()) {
int i = heap.top().se;
int cur = -heap.top().fi;
heap.pop();
// cout << i << " " << cur << endl;
if (val[i] != cur)
continue;
ans += cur;
val[i] = -1e9;
for (int j = i; j <= mx; j += i)
if (mini(val[p[j]], p[j] - j))
heap.push(mp(-val[p[j]], p[j]));
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
42992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
43356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
10308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
8872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
10316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
2860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
166 ms |
81924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
321 ms |
88068 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
74180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |