Submission #889437

# Submission time Handle Problem Language Result Execution time Memory
889437 2023-12-19T16:44:33 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
1512 ms 85124 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int, int>

int main()
{
    int n;
    cin >> n;
    vector<int> nums(n);
    set<pii> num;
    for(int i = 0; i < n; i++)
    {
        cin >> nums[i];
        num.insert({nums[i], i});
    }
    sort(nums.begin(), nums.end());
    set<int> mult;
    for (int j = nums[0]; j <=1e7; j+=nums[0])
    {
        mult.insert(j);
    }
    ll sol = 0;

    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0,0});
    for(int i = 1; i < n; i++) pq.push({nums[i], i});
    vector<bool> vis(n, 0);

    while (pq.size())
    {
        int i, d;
        tie(d, i) = pq.top();
        pq.pop();
        if (vis[i]) continue;
        vis[i] = true;
        num.erase({nums[i], i});
        for (int j = nums[i]; j <=1e7; j+=nums[i])
        {
            auto u = num.lower_bound({j, 0});
            if (u != num.end()) pq.push({(*u).first-j, (*u).second});
        }
        sol+=d;
    }
    cout << sol;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 234 ms 47460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 720 ms 63180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 24528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1512 ms 77408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 649 ms 85124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 514 ms 28616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 737 ms 57120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 4032 KB Output isn't correct
2 Halted 0 ms 0 KB -