-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkakao-10.cpp
More file actions
39 lines (36 loc) · 910 Bytes
/
kakao-10.cpp
File metadata and controls
39 lines (36 loc) · 910 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
37
38
39
// 크레인 인형뽑기 게임
// 2020.04.05
#include<string>
#include<vector>
#include<stack>
using namespace std;
int solution(vector<vector<int>> board, vector<int> moves)
{
int answer = 0;
int n = board.size();
stack<int> busket;
for (int i = 0; i < moves.size(); i++)
{
int num = moves[i] - 1;
for (int j = 0; j < n; j++)
{
if (board[j][num] != 0)
{
// 옮긴게 같은거라면 터짐
if (!busket.empty() && busket.top() == board[j][num])
{
busket.pop();
answer += 2;
board[j][num] = 0;
}
else
{
busket.push(board[j][num]);
board[j][num] = 0;
}
break;
}
}
}
return answer;
}