Skip to content

Commit

Permalink
주석 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
makehard23 committed Jul 2, 2024
1 parent 4edb6ff commit c1fae0b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions yuyu0830/위상정렬/1005.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ int f() {
deque<bool> visited(n + 1, 0);
vector<int> arr(n + 1, 0), enter(n + 1, 0), rule[n + 1];

// 건물 짓는 속도
for (int i = 1; i <= n; i++)
cin >> arr[i];

// 건물 순서
for (int i = 0; i < m; i++) {
int a, b; cin >> a >> b;
rule[a].push_back(b);
Expand All @@ -28,7 +30,10 @@ int f() {
vector<int> tmp[2];
bool e = false;

// 원하는 건물 지을 수 있을 때까지 반복
while (true) {
// ret 시간에 지을 수 있는 건물들 탐색 및 tmp 큐에 push
// 원하는 건물을 지을 수 있으면 함수 종료 및 값 반환
for (int i = 1; i <= n; i++) {
if (!enter[i] && !visited[i]) {
if (i == t) return ret + arr[i];
Expand All @@ -40,8 +45,10 @@ int f() {

int m = 99999999;

// 지금 짓고있는 건물 + 지을 수 있는 건물 중 시간 가장 적게 남은 값 탐색
for (int i : tmp[e]) { m = min(m, arr[i]); }

// tmp 큐에 있는 모든 건물들 m만큼 건설 진행, 완성되면 큐에서 제거
while (!tmp[e].empty()) {
int a = tmp[e].back();
tmp[e].pop_back();
Expand Down

0 comments on commit c1fae0b

Please sign in to comment.