Submission #889455

# Submission time Handle Problem Language Result Execution time Memory
889455 2023-12-19T18:49:30 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
2729 ms 83168 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;
            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 600 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 999 ms 34896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 9000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2729 ms 41860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1581 ms 65620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1853 ms 83168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 11156 KB Output isn't correct
2 Halted 0 ms 0 KB -