핵심 풀이 : 첫 번째는 핵심은 10시에 시작하면 (10 + k ) 까지의 시간까지 증설한 서버가 유지된다고 생각하였음
두 번째는 현재 서버가 얼만큼 증설 되었는지를 알아야 하기에 currentV라는 변수를 사용해서 누적시켰음
나머지는 문제에 나오는대로 조건을 잘 지키면 됨
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> players, int m, int k) {
int answer = 0;
int currentV = 0;
vector<int> vec(25+k, 0);
int ct = 0;
for(auto i : players) {
if(currentV < i / m) {
int ns = (i / m) - currentV;
vec[ct+k-1] = ns;
currentV += ns;
answer+= ns;
}
currentV -= vec[ct];
ct++;
}
return answer;
}
'개발 > 알고리즘' 카테고리의 다른 글
위상 정렬 - Topological Sort ) (1) | 2025.05.22 |
---|---|
Thread (1) | 2025.05.12 |
비트마스크 알고리즘 (0) | 2025.05.11 |
백준 2230) 수 고르기 골드 5 투 포인터 (0) | 2024.12.10 |
백준 1038) 감소하는 수 골드 5 - 백트래킹 (0) | 2024.12.10 |