일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 개발자
- EOI
- C++
- 알고리즘
- 선형대수
- 머신러닝
- Deep learning
- 컴퓨터과학과
- leetcode
- 프로그래머스
- LAA
- machine learning
- 캐나다 영주권
- 기본
- 방통대
- mpnp
- 조지아텍
- omscs
- MATLAB
- zeros
- LV1
- 매트랩
- 온라인석사
- 방송통신대학교
- cpp
- 마니토바
- 주정부이민
- Plotting
- 딥러닝
- 코딩테스트
Archives
- Today
- Total
Krononberg
크레인 인형뽑기 c++풀이 본문
#include <string>
#include <vector>
using namespace std;
int solution(vector<vector<int>> board, vector<int> moves) {
int answer = 0;
vector <int> container;
int temp =0;
for(int m = 0; m<moves.size(); m++){
for(int i = 0; i<board.size(); i++){
if(board[i][moves[m]-1] != 0){
temp = board[i][moves[m]-1];
board[i][moves[m]-1] = 0;
if(container.empty())
container.push_back(temp);
else{
if(container.back()==temp){
answer+=2;
container.pop_back();
}
else
container.push_back(temp);
}
break;
}
}
}
return answer;
}
'개발 로그 > 알고리즘' 카테고리의 다른 글
프로그래머스) 완주하지못한 선수 c++ (0) | 2021.08.27 |
---|---|
프로그래머스 - 직업군 추천하기 C++ (0) | 2021.08.23 |
leetcode 1859. Sorting the Sentence.cpp (0) | 2021.06.21 |
프로그래머스 lv2 테스트 2번 :카펫 c++ 풀이 (0) | 2021.06.14 |
프로그래머스 lv2 테스트 :숫자의 표현 c++ 풀이 (0) | 2021.06.14 |