2240번

· 백준
코드#include #include using namespace std;int t,w,a[1003], dp[3][32][1003]; // 상태 3개 필요int go(int loc, int cnt, int idx) { if(cnt > w) return -987654321; // 움직이는 횟수가 넘은 경우 if(idx == t) return 0; if(dp[loc][cnt][idx] != -1) return dp[loc][cnt][idx]; // 3-loc을 하면 1또는 2가 나온다 int move = (a[idx] == loc ? 0 : 1) + go(3 - loc, cnt + 1, idx + 1); int stop = (a[idx] == loc ? 1 : 0) + ..