Submission #889456

# Submission time Handle Problem Language Result Execution time Memory
889456 2023-12-19T18:50:27 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
2751 ms 82540 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<int> mult;
    set<int> num;
    map<int, bool> v;
    map<int, int> mini;
    for(int i = 0; i < n; i++)
    {
        cin >> nums[i];
        if (v[nums[i]]) continue;
        num.insert(nums[i]);
        mini[nums[i]]=1e9;
        v[nums[i]]=true;
    }
    sort(nums.begin(), nums.end());
    ll sol = 0;
    mini[nums[0]] = 0;

    for (int ele:nums)
    {
        int mn = mini[ele];
        num.erase(ele);
        if (num.empty())
        {
            cout << sol+mn << endl;
            break;
        }
        for (int j = ele; j <= *(--num.end()); j+=ele)
        {
            auto u = num.lower_bound(j);
            if (u != num.end())
            {
                int iu = *u;
                mini[iu]=min(mini[iu], iu-j);
                mn = min(mn, iu-j);
            }
            mult.insert(j);
        }
        sol += mn;
    }

    return 0;
}
# 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 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1022 ms 34288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 9040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2751 ms 41164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 10660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1516 ms 64700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1781 ms 82540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 11056 KB Output isn't correct
2 Halted 0 ms 0 KB -