-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF.cpp
More file actions
36 lines (35 loc) · 674 Bytes
/
F.cpp
File metadata and controls
36 lines (35 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//F
#include<iostream>
using namespace std;
int main() {
int M = 0;
int N = 0;
cin >> N >> M;
long int dicM[M];
for(int i = 0; i < M; i++){
int ayuda = 0;
cin >> ayuda;
dicM[i]= ayuda;
}
long long int dic[N];
dic[0] = 1;
for(int i = 0; i<N; i++){
dic[i] = 1;
}
for(int i = 0; i < M; i ++){
dic[dicM[i]]= 0;
}
int contador = 0;
for(int i = 0; i < N; i++){
if(dic[i]+dic[i+1]+dic[i+2] == 3){
contador = contador + 2;
}
else if(dic[i]+dic[i+1]+dic[i+2] == 2){
contador = contador +1;
}
else{
contador = contador + 0;
}
}
cout << contador << endl;
}