-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
724a86e
commit 5a62fe9
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// progresse와 speed를 넘기면 작업 시간을 반환해주는 함수 | ||
// 반복으로 작업시간을 가지고 | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <queue> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
vector<int> solution(vector<int> progresses, vector<int> speeds) { | ||
vector<int> result; | ||
queue<int> daysQueue; | ||
|
||
for (size_t i = 0; i < progresses.size(); ++i) { | ||
int remainingProgress = 100 - progresses[i]; | ||
int days = (remainingProgress + speeds[i] - 1) / speeds[i]; | ||
daysQueue.push(days); | ||
} | ||
|
||
while (!daysQueue.empty()) { | ||
int currentDay = daysQueue.front(); | ||
daysQueue.pop(); | ||
int count = 1; | ||
|
||
while (!daysQueue.empty() && daysQueue.front() <= currentDay) { | ||
daysQueue.pop(); | ||
count++; | ||
} | ||
|
||
result.push_back(count); | ||
} | ||
|
||
return result; | ||
} |