diff --git a/week17/B_31997/hyxrxn/31997.cpp b/week17/B_31997/hyxrxn/31997.cpp new file mode 100644 index 0000000..b96e13d --- /dev/null +++ b/week17/B_31997/hyxrxn/31997.cpp @@ -0,0 +1,40 @@ +#include +#include +using namespace std; + +int n, m, t; +int arrive[202020]; +int leave[202020]; +long long st[202020]; +long long et[202020]; + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> n >> m >> t; + for (int i = 1; i <= n; i++) { + cin >> arrive[i] >> leave[i]; + } + + int c, d, s, e; + for (int i = 0; i < m; i++) { + cin >> c >> d; + s = max(arrive[c], arrive[d]); + e = min(leave[c], leave[d]); + if (s < e) { + st[s]++; + et[e]++; + } + } + + cout << st[0] - et[0] << "\n"; + for (int i = 1; i < t; i++) { + st[i] += st[i - 1]; + et[i] += et[i - 1]; + cout << st[i] - et[i] << "\n"; + } + + return 0; +} \ No newline at end of file diff --git a/week17/C_31932/hyxrxn/31932.cpp b/week17/C_31932/hyxrxn/31932.cpp new file mode 100644 index 0000000..240f58a --- /dev/null +++ b/week17/C_31932/hyxrxn/31932.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +using namespace std; + +// 도착지점을 갈 수 있는 빙하 탐색하며 그 빙하에 도달할 수 있는 최댓값 갱신 +// 반복하며 시작 지점의 도달 최댓값 갱신 +// 도달 최댓값이 먹을 수 있는 연어의 최대 수일듯... + +int n, m; +vector>> vec(101010); +priority_queue> pq; +int visit[101010] = {0}; +int until[101010] = {0}; + +int main() { + cin >> n >> m; + + int u, v, d, t; + for (int i = 0; i < m; i++) { + cin >> u >> v >> d >> t; + vec[u].push_back({v, d, t}); + vec[v].push_back({u, d, t}); + } + + until[1] = -1; + visit[n] = 1; + for (const auto &item: vec[n]) { + int next = get<0>(item); + int dis = get<1>(item); + int tim = get<2>(item); + + if (tim - dis >= 0) { + until[next] = max(until[next], tim - dis); + pq.push({until[next], next}); + } + } + + while (!pq.empty()) { + pair a = pq.top(); + pq.pop(); + int pre = a.second; + int now = a.first; + visit[pre] = 1; + + for (const auto &item: vec[pre]) { + int next = get<0>(item); + int dis = get<1>(item); + int tim = get<2>(item); + + if (visit[next] == 0 && now <= tim) { + until[next] = max(until[next], now - dis); + pq.push({until[next], next}); + } + } + } + + cout << until[1]; + + return 0; +} + +// 18에서 런타임에러 \ No newline at end of file