-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquestion5.c
147 lines (116 loc) · 2.56 KB
/
question5.c
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
TO BE DONE
http://practice.geeksforgeeks.org/problems/maximize-dot-product/0
*/
#include <stdio.h>
#include <stdlib.h>
unsigned long long int findProduct(int n, int m int *a, int *b){
unsigned long long int dp[n+1][m+1];
memset(dp,0,sizeof(dp[0][0]));
int i,j;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%llu ", dp[i][j]);
}
printf("\n");
}
}
int main(){
int cases;
scanf("%d", &cases);
int i;
int n,m;
for(i=0;i<cases;i++){
scanf("%d %d", &n, &m);
int a[n];
int b[m];
int j;
for(j=0;j<n;j++){
scanf("%d",&a[j]);
}
for(j=0;j<m;j++){
scanf("%d",&b[j]);
}
printf("%llu\n", findProduct(n,m,a,b));
}
return 0;
}
// struct node{
// int index;
// int value;
// struct node *next;
// };
// void minHeapify(struct node *arr,int i, int size){
// int left = 2*i+1,right=2*i+2,smallest, heapSize = size;
// if(left <= heapSize-1 && arr[i].value < arr[left].value){
// smallest = i;
// }else{
// smallest = left;
// }
// if(right <= heapSize-1 && arr[right].value < arr[smallest].value){
// smallest = right;
// }
// if(smallest <= heapSize - 1 && smallest !=i){
// struct node *temp = (struct node *)malloc(sizeof(struct node));
// temp->value = arr[smallest].value;
// temp->index = arr[smallest].index;
// arr[smallest].index = arr[i].index;
// arr[smallest].value = arr[i].value;
// arr[i].value = temp->value;
// arr[i].index = temp->index;
// minHeapify(arr,smallest,size);
// }
// }
// int deleteMax(struct node *arr, int *size){
// if(*size < 1){
// return -1;
// }
// struct node *temp = (struct node *)malloc(sizeof(struct node));
// int result = arr[0].value;
// arr[0] = arr[*size-1];
// *size = *size-1;
// maxHeapify(arr,0,*size);
// return result;
// }
// unsigned long long int findProduct(int n, int m, int *a, int *b){
// int diff = n-m;
// unsigned long long int prod = 0;
// int index = floor(n/2);
// int i;
// struct node *copyArr[n];
// for(i=0;i<n;i++){
// copyArr[i].value = a[i];
// copyArr[i].index = i;
// }
// for(i = index; i>=0;i--){
// minHeapify(copyArr,i,size);
// }
// int j = 0;
// i = 0;
// while(i < n && j < m){
// prod += a[j]*b[j];
// i++;
// j++;
// }
// return prod;
// }
// int main(){
// int cases;
// scanf("%d", &cases);
// int i;
// int n,m;
// for(i=0;i<cases;i++){
// scanf("%d %d", &n, &m);
// int a[n];
// int b[m];
// int j;
// for(j=0;j<n;j++){
// scanf("%d",&a[j]);
// }
// for(j=0;j<m;j++){
// scanf("%d",&b[j]);
// }
// printf("%llu\n", findProduct(n,m,a,b));
// }
// return 0;
// }