# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481717 |
2021-10-21T13:10:42 Z |
Johann |
Sirni (COCI17_sirni) |
C++14 |
|
5000 ms |
1100 KB |
// https://oj.uz/problem/view/COCI17_sirni
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vb vector<bool>
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
vi cards(n);
for (int i = 0; i < n; i++) {
cin >> cards[i];
}
sort(cards.begin(), cards.end());
int next = 0, curr = 0;
vb visited(n, false);
ll total = 0;
vi dists(n, INT_MAX);
for (int i = 0; i < n-1; i++) {
curr = next;
next = 0;
visited[curr] = true;
int current_value = cards[curr];
for (int v = 0; v < curr; v++) {
if (visited[v]) continue;
dists[v] = min(dists[v], current_value % cards[v]);
if (dists[v] < dists[next]) next = v;
}
for (int v = curr+1; v < n; v++) {
if (visited[v]) continue;
dists[v] = min(dists[v], cards[v] % current_value);
if (dists[v] < dists[next]) next = v;
}
total += (ll) dists[next];
}
cout << total << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
4 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5039 ms |
1100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
736 ms |
404 KB |
Output is correct |
2 |
Execution timed out |
5052 ms |
1100 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5064 ms |
1100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5062 ms |
588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5035 ms |
1100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5076 ms |
1100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1509 ms |
460 KB |
Output is correct |
2 |
Execution timed out |
5075 ms |
1100 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |