Submission #1042284

# Submission time Handle Problem Language Result Execution time Memory
1042284 2024-08-02T19:15:12 Z Abito Sirni (COCI17_sirni) C++17
0 / 140
1245 ms 230740 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=1e6+5;
int a[N],n;
set<int> ad[N],er[N],s;
bool b[N];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i],b[a[i]]=1;
    for (int i=1;i<N;i++){
        if (!b[i]) continue;
        for (int j=i;j<N;j+=i){
            if (j!=i) ad[j].ep(j);
            if (j+i<N) er[j+i].ep(j);
        }
    }
    int ans=0;
    for (int i=1;i<N;i++){
        for (auto u:ad[i]) s.ep(u);
        if (b[i] && !s.empty()){
            //cout<<i<<endl;
            //for (auto u:s) cout<<u<<' ';cout<<endl;
            ans+=i-(*--s.end());
        }
        if (b[i]) s.ep(i);
        for (auto u:er[i]) s.erase(u);
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 91 ms 191880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 385 ms 151960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 91 ms 191572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 544 ms 164528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 125 ms 110280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1245 ms 230740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 932 ms 212304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 112 ms 194556 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 118 ms 194384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 90 ms 193192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -