-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path17952.cpp
More file actions
60 lines (56 loc) · 1.17 KB
/
17952.cpp
File metadata and controls
60 lines (56 loc) · 1.17 KB
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
55
56
57
58
59
60
// 17952. 과제는 끝나지 않아!
// 2019.12.12
// 구현
#include<iostream>
#include<algorithm>
#include<deque>
using namespace std;
struct assignment
{
int score;
int time;
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ans = 0;
int n;
cin >> n;
deque<assignment> assignments;
while (n-- > 0)
{
int k;
cin >> k;
if (k == 1)
{
int score, time;
cin >> score >> time;
assignment cur;
cur.score = score;
cur.time = time - 1;
// 현재 추가된 과제의 시간이 1초짜리면 그냥 점수 추가
if (cur.time == 0)
{
ans += cur.score;
}
// 아니면 맨 앞에 넣음
else
{
assignments.push_front(cur);
}
}
else
{
assignments.front().time--;
if (assignments.front().time == 0)
{
ans += assignments.front().score;
assignments.pop_front();
}
}
}
cout << ans << "\n";
return 0;
}