Submission #889461

# Submission time Handle Problem Language Result Execution time Memory
889461 2023-12-19T19:02:03 Z codefox Sirni (COCI17_sirni) C++14
0 / 140
5000 ms 233068 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;
    for(int i = 0; i < n; i++)
    {
        cin >> nums[i];
        num.insert(nums[i]);
        n2.insert(nums[i]);
    }
    sort(nums.begin(), nums.end());
    ll sol = 0;

    for (int ele:n2)
    {
        int mn = 1e9;
        auto o = mult.upper_bound(ele);
        if (o != mult.begin())
        {
            o--;
            mn = min(mn, ele-*o);
        }
        else mn = 0;
        num.erase(ele);
        for (int j = ele; j <= 1e7; j+=ele)
        {
            auto u = num.lower_bound(j);
            if (u != num.end())
            {
                int iu = *u;
                mn = min(mn, iu-j);
            }
            mult.insert(j);
        }
        sol += mn;
    }
    cout << sol;

    return 0;
}
# 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 5048 ms 192088 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 5059 ms 170172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1060 ms 70808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5051 ms 192352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 233068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1157 ms 60344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1469 ms 78348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 10068 KB Output isn't correct
2 Halted 0 ms 0 KB -