Submission #889430

# Submission time Handle Problem Language Result Execution time Memory
889430 2023-12-19T16:37:52 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
1481 ms 85188 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});
    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;
        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 235 ms 47696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 690 ms 60836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 24652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1481 ms 79016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 626 ms 85188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 488 ms 29520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 709 ms 57520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 4144 KB Output isn't correct
2 Halted 0 ms 0 KB -