-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path416C - Booking System.cpp
More file actions
108 lines (63 loc) · 1.41 KB
/
416C - Booking System.cpp
File metadata and controls
108 lines (63 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <bits/stdc++.h>
using namespace std;
struct cadeira{
int id,t;
};
struct request{
int id,t,v;
};
bool Rordena(request ant,request dps){
if(ant.v > dps.v){
return true;
}else if(ant.v == dps.v){
if(ant.t < dps.t) return true;
}
return false;
}
bool Cordena(cadeira ant,cadeira dps){
if(ant.t < dps.t) return true;
return false;
}
bool usou[2000];
int main(){
int n,k;
cin >> n;
request r[n];
for(int i=0;i<n;i++){
scanf("%d%d",&r[i].t,&r[i].v);
r[i].id = i+1;
}
sort(r,r+n,Rordena);
cin >> k;
cadeira c[k];
for(int i=0;i<k;i++){
scanf("%d",&c[i].t);
c[i].id = i+1;
}
sort(c,c+k,Cordena);
vector < pair <int,int> > saida;
int soma = 0;
for(int i=0;i<n;i++){
int solicitacao = r[i].id;
bool conseguiu = false;
int lugar = -1;
for(int j=0;j<k;j++){
int id_cadeira = c[j].id;
if(c[j].t >= r[i].t && !usou[id_cadeira]){
usou[id_cadeira] = true;
conseguiu = true;
lugar = id_cadeira;
break;
}
}
if(conseguiu){
saida.push_back(make_pair(solicitacao,lugar));
soma += r[i].v;
}
}
cout << saida.size() << " " << soma << endl;
for(int i=0;i<saida.size();i++){
cout << saida[i].first << " " << saida[i].second << endl;
}
return 0;
}