-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-13.cpp
More file actions
54 lines (52 loc) · 883 Bytes
/
2-13.cpp
File metadata and controls
54 lines (52 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 기능개발
// 2019.06.28
// 스택
#include<vector>
#include<deque>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds)
{
vector<int> answer;
deque<int> dq;
deque<int> speedsDQ;
for (int i = 0; i < progresses.size(); i++)
{
dq.push_back(progresses[i]);
speedsDQ.push_back(speeds[i]);
}
int n = progresses.size();
while (!dq.empty())
{
for (int i = 0; i < dq.size(); i++)
{
dq[i] += speedsDQ[i];
}
if (dq.front() >= 100)
{
int count = 0;
for (int i = 0; i < dq.size(); i++)
{
if (dq[i] < 100 || dq.empty())
{
answer.push_back(count);
break;
}
else
{
count++;
if (i == dq.size() - 1)
{
answer.push_back(count);
break;
}
}
}
for (int i = 0; i < count; i++)
{
dq.pop_front();
speedsDQ.pop_front();
}
}
}
return answer;
}