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