Submission #889459

# Submission time Handle Problem Language Result Execution time Memory
889459 2023-12-19T18:56:43 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
5000 ms 235836 KB
#include <bits/stdc++.h>

using namespace std;

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

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

    for (int ele:n2)
    {
        int mn = mini[ele];
        num.erase(ele);
        for (int j = ele; j <= 1e7; 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;
    }
    cout << sol;

    return 0;
}
# 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 Execution timed out 5074 ms 191620 KB Time limit exceeded
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 Execution timed out 5052 ms 176160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1123 ms 71808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5112 ms 198312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5032 ms 235836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1454 ms 66532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1707 ms 84516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 11392 KB Output isn't correct
2 Halted 0 ms 0 KB -