Cod sursa(job #3299197)
| Utilizator | Data | 5 iunie 2025 03:19:38 | |
|---|---|---|---|
| Problema | Stramosi | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("timbre.in");
ofstream fout("timbre.out");
int n, m, k;
priority_queue<pair<int, int>> pq;
priority_queue<int, vector<int>, greater<>> cost;
int main(){
int s, c, i;
long long sol = 0;
fin >> n >> m >> k;
for (i = 1; i <= m; i++){
fin >> s >> c;
pq.emplace(s, c);
}
while (n){
while (!pq.empty() && pq.top().first >= n){
cost.push(pq.top().second);
pq.pop();
}
sol += cost.top();
cost.pop();
n -= k;
}
fout << sol;
return 0;
}