From 118068dd12aef3b2842a7d57a23df94c29b38a1a Mon Sep 17 00:00:00 2001 From: hyxrxn Date: Mon, 9 Sep 2024 18:47:28 +0900 Subject: [PATCH 1/2] =?UTF-8?q?31997=20-=20[=EC=A6=90=EA=B1=B0=EC=9A=B4=20?= =?UTF-8?q?=ED=9A=8C=EC=9D=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week17/B_31997/hyxrxn/31997.cpp | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 week17/B_31997/hyxrxn/31997.cpp 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 From a4f6b7a3b47933f0ae61c05c4c2b5dba9f8dd519 Mon Sep 17 00:00:00 2001 From: hyxrxn Date: Mon, 9 Sep 2024 18:48:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?31932=20-=20[=EB=82=98=EB=8A=94=20=EB=B6=81?= =?UTF-8?q?=EA=B7=B9=EA=B3=B0=EC=9E=85=EB=8B=88=EB=8B=A4]=20(=EB=9F=B0?= =?UTF-8?q?=ED=83=80=EC=9E=84=EC=97=90=EB=9F=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week17/C_31932/hyxrxn/31932.cpp | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 week17/C_31932/hyxrxn/31932.cpp 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