# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481715 |
2021-10-21T13:03:02 Z |
Johann |
Sirni (COCI17_sirni) |
C++14 |
|
5000 ms |
1868 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];
}
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;
for (int v = 0; v < n; v++) {
if (visited[v]) continue;
dists[v] = min(dists[v], min(cards[curr] % cards[v], cards[v] % cards[curr]));
if (dists[v] < dists[next]) next = v;
}
total += (ll) dists[next];
}
cout << total << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
204 KB |
Output is correct |
2 |
Correct |
7 ms |
328 KB |
Output is correct |
3 |
Correct |
7 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
204 KB |
Output is correct |
2 |
Correct |
7 ms |
204 KB |
Output is correct |
3 |
Correct |
7 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
6 ms |
204 KB |
Output is correct |
3 |
Correct |
7 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5043 ms |
1740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1447 ms |
496 KB |
Output is correct |
2 |
Execution timed out |
5029 ms |
1484 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5049 ms |
1740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5042 ms |
844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5049 ms |
1868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5050 ms |
1868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2855 ms |
608 KB |
Output is correct |
2 |
Execution timed out |
5071 ms |
1612 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |