-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGCAC.cpp
More file actions
78 lines (71 loc) · 1.08 KB
/
GCAC.cpp
File metadata and controls
78 lines (71 loc) · 1.08 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
#include <iostream>
#include<vector>
using namespace std;
int main() {
int t;
cin>>t;
while(t>0){
int m;
int n;
cin>>n;
cin>>m;
vector<long long int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
vector<vector <int>> b(m, vector<int> (3,0));
for(int i=0;i<m;i++){
for(int j=0;j<2;j++){
cin>>b[i][j];
}
}
for(int i=0;i<m;i++){
b[i][2]=0;
}
vector<string> c(n);
for(int i=0;i<n;i++){
cin>>c[i];
}
vector<int> d(n);
for(int i=0;i<n;i++){
long long int sum=0;
int k=0;
for(int j=0;j<m;j++){
if(c[i][j]=='1'){
if(b[j][1]>0){
if(b[j][0]>sum){
sum=b[j][0];
k=j;
}
}
}
}
if(sum>=a[i]){
b[k][1]--;
b[k][2]++;
k=k+1;
}
else{
k=0;
}
d[i]=k;
}
long long int sum=0;
int l=0;
for(int i=0;i<n;i++){
if(d[i]>0){
l++;
sum=sum+b[d[i]-1][0];
}
}
int z=0;
for(int i=0;i<m;i++){
if(b[i][2]==0){
z++;
}
}
cout<<l<<" "<<sum<<" "<<z<<endl;
t--;
}
return 0;
}