Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
- using namespace std;
- typedef struct trab{
- int v, t;
- } trab;
- int compare(trab a, trab b){
- return a.t < b.t;
- }
- int main(){
- optimizar_io;
- int N, H;
- while (cin >> N >> H){
- trab arr[N];
- for(int i = 0; i < N ; i++) {
- cin >> arr[i].v >> arr[i].t;
- }
- qsort(arr, N, sizeof(trab), compare);
- trab entryByHour[H+1];
- int loss = 0;
- for(int i=0;i<N;i++){
- int j= arr[i].t-1;
- while(j>=0 && entryByHour[j].t != NULL) j--;
- if(j < 0) loss += arr[i].v;
- else entryByHour[j] = arr[i];
- }
- cout << loss << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement