[programmers/c++] 체육복
#include #include using namespace std; int solution(int n, vector lost, vector reserve) { int answer = 0; vector student(n+1, 1); for (int s : lost) student[s] -= 1; for (int s : reserve) student[s] += 1; for (int i=1;i1 && student[i-1] > 1) { student[i-1]--; student[i]++; } else if (i 1) { student[i+1]--; student[i]++; } } } for (int i=1;i 0) answer++; return answer; } 의아한 점 왜 앞 사람 먼저 빌려주는 게 맞는..
Algorithm
2022. 6. 15. 09:30