문제
코딩테스트 연습 - 무지의 먹방 라이브 | 프로그래머스 스쿨 (programmers.co.kr)
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
코드
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> food_times, long long k) {
int answer=0;
vector<long long> arr;
int check=0;
while (check<food_times.size()){
if (food_times[answer]!=0) {
arr.push_back(answer);
food_times[answer]--;
check=0;
}
else
check++;
answer++;
answer %= food_times.size();
}
if(k>=arr.size())
return -1;
else
answer=arr[k]+1;
return answer;
}
풀이
정확성 통과 효율성 탈락
'코테 > Greedy' 카테고리의 다른 글
[C/C++] 백준 11399, Greedy (0) | 2023.02.09 |
---|---|
[C/C++] 백준 1931, Greedy (0) | 2023.02.09 |
[C/C++] 나동빈 볼링공 고르기, Greedy (0) | 2023.02.07 |
[C/C++] 나동빈 만들 수 없는 금액, Greedy (0) | 2023.02.07 |
[C/C++] 백준 1439, Greedy (0) | 2023.02.06 |