#include<stdio.h> #include<queue> #include<algorithm> using namespace std; int n; pair<int, int> p[200000]; priority_queue<int> pq; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d %d", &p[i].first, &p[i].second); sort(p, p + n); int res = 0; for (int i = 0; i < n; i++) { res += p[i].second; pq.push(-p[i].second); while (pq.size() > p[i].first) res += pq.top(), pq.pop(); } printf("%d", res); return 0; }
1781번: 컵라면
https://www.acmicpc.net/problem/1781
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기