# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234872 | 2020-05-26T06:27:46 Z | mahmoudbadawy | Sirni (COCI17_sirni) | C++17 | 479 ms | 118520 KB |
#include <bits/stdc++.h> using namespace std; const int N=1e7+7; int n; int got[N],vis[N],inarr[N]; int main() { scanf("%d",&n); int mn=N; for(int i=0;i<n;i++) { int x; scanf("%d",&x); got[x]=1; inarr[x]=1; mn=min(mn,x); } vis[mn]=1; for(int i=1;i<N;i++) { if(!got[i]) continue; if(vis[i]==0 || i==mn) { for(int j=2*i;j<N;j+=i) { if(inarr[j]) vis[i]|=vis[j]; vis[j]=got[j]=1; } } } long long ans=0,las=-1; for(int i=1;i<N;i++) { if((!vis[i]) && inarr[i]) ans+=i-las; if(got[i]) las=i; } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 34688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 242 ms | 78876 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 36728 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 326 ms | 83320 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 134 ms | 82680 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 479 ms | 83308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 350 ms | 79736 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 163 ms | 118520 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 170 ms | 118520 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 103 ms | 112892 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |