링크 : https://school.programmers.co.kr/learn/courses/30/lessons/42862
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int arr[31] = {0, };
int solution(int n, vector<int> lost, vector<int> reserve) {
int answer = 0;
for(int i: lost)
arr[i]--;
for(int i: reserve)
arr[i]++;
for(int i = 1; i <= n; i++){
if(arr[i] == -1){
if(arr[i-1] == 1){
arr[i-1] = arr[i] = 0;
}
else if(arr[i+1] == 1){
arr[i+1] = arr[i] = 0;
}
}
if(arr[i] >= 0) answer++;
}
return answer;
}