-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGCAC.cpp
57 lines (56 loc) · 1.6 KB
/
GCAC.cpp
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
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m,totalcandidates=0,companyhired;
//vector< vector<int> >mat(1005,vector<int>(1005));
cin>>n>>m;
bool markcompany[m];
companyhired=m;
long int minsalary[n],offeredsalary[m],maxjoboffers[m];
long long int totalsalary=0;
for(int i=0;i<n;i++)
cin>>minsalary[i];
for(int i=0;i<m;i++)
{
cin>>offeredsalary[i]>>maxjoboffers[i];
markcompany[i]=1;
}
for(int i=0;i<n;i++)
{
long int maxsalary=0;
int jobindex=-1;
string s;
cin>>s;
for(int j=0;j<m;j++)
{
if(s[j]=='1')
{
//mat[i].push_back(j);
if((offeredsalary[j]>maxsalary&&offeredsalary[j]>=minsalary[i])&&maxjoboffers[j]>0)
{
maxsalary=offeredsalary[j];
jobindex=j;
}
}
}
if(jobindex!=-1)
{
maxjoboffers[jobindex]--;
totalsalary+=offeredsalary[jobindex];
totalcandidates++;
if(markcompany[jobindex])
{
companyhired--;
markcompany[jobindex]=0;
}
}
}
cout<<totalcandidates<<" "<<totalsalary<<" "<<companyhired<<" "<<endl;
}
}