diff --git a/src/week5/BOJ1781/BOJ1781_V1.cpp b/src/week5/BOJ1781/BOJ1781_V1.cpp new file mode 100644 index 0000000..2e79abf --- /dev/null +++ b/src/week5/BOJ1781/BOJ1781_V1.cpp @@ -0,0 +1,37 @@ +#include +using namespace std; +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + vector> inp; + int n; + cin >> n; + for (int i=0; i> d >> c; + inp.push_back({d,c}); + } + + sort(inp.begin(), inp.end()); + priority_queue, greater> pq; + for (auto [d,p] : inp) { + pq.push(p); + if (pq.size() > d) { + pq.pop(); + } + } + + int ret=0; + while(!pq.empty()) { + ret += pq.top(); + pq.pop(); + } + + cout << ret << '\n'; + + + return 0; +} \ No newline at end of file