From 7cddea0e6bfaea1adece632ae9a939e5a2d8a174 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Wed, 8 Jul 2026 16:58:25 +0900 Subject: [PATCH] =?UTF-8?q?14469=20:=20=EC=86=8C=EA=B0=80=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=84=20=EA=B1=B4=EB=84=88=EA=B0=84=20=EC=9D=B4=EC=9C=A0=20?= =?UTF-8?q?3=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week5/BOJ14469/BOJ14469_V1.cpp | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/week5/BOJ14469/BOJ14469_V1.cpp diff --git a/src/week5/BOJ14469/BOJ14469_V1.cpp b/src/week5/BOJ14469/BOJ14469_V1.cpp new file mode 100644 index 0000000..7b0da77 --- /dev/null +++ b/src/week5/BOJ14469/BOJ14469_V1.cpp @@ -0,0 +1,43 @@ +#include +using namespace std; +struct cmp { + bool operator() (pair a, pair b){ + if (a.first != b.first) + return a.first > b.first; + + return a.second > b.second; + } +}; +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + int n; + cin >> n; + + priority_queue, vector>, cmp> pq; + for (int i=0; i> arrive >> how; + pq.push({arrive, how}); + } + + + + int t=1; + while(!pq.empty()) { + if (pq.top().first <= t) { + t += pq.top().second; + pq.pop(); + } else { + t = pq.top().first + pq.top().second; + pq.pop(); + } + } + + cout << t; + + return 0; +} \ No newline at end of file