# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1004193 |
2024-06-21T06:20:00 Z |
Nelt |
Sirni (COCI17_sirni) |
C++17 |
|
5000 ms |
2780 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
ll n;
cin >> n;
ll p[n];
for (ll &i : p) cin >> i;
ll ans = 0;
ll mn[n];
for (ll i = 0; i < n; i++) mn[i] = 1e9;
mn[0] = 0;
bool used[n];
memset(used, 0, sizeof(used));
for (ll i = 0; i < n; i++)
{
ll cur = 1e9;
ll v = 0;
for (ll j = 0; j < n; j++) if (!used[j] and mn[j] < cur) cur = mn[j], v = j;
ans += cur;
used[v] = 1;
for (ll j = 0; j < n; j++) mn[j] = min(mn[j], min(p[v] % p[j], p[j] % p[v]));
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// precomp();
// cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
// cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
600 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
348 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
600 KB |
Output is correct |
2 |
Correct |
5 ms |
480 KB |
Output is correct |
3 |
Correct |
6 ms |
484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5051 ms |
2648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1102 ms |
604 KB |
Output is correct |
2 |
Execution timed out |
5078 ms |
2392 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5077 ms |
2632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5031 ms |
1112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5079 ms |
2648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5063 ms |
2780 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2353 ms |
920 KB |
Output is correct |
2 |
Execution timed out |
5037 ms |
2648 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |