-
Notifications
You must be signed in to change notification settings - Fork 1
/
3.c
122 lines (72 loc) · 2.37 KB
/
3.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
// Given n complex products, each with name, price and weight, find out how many duplicates of the original product are present within the products. Here, a duplicate is a product with all parameters, i.e. name, price and weight, equal to some other product.
// Complete the code in the editor below. The program has to return a single integer denoting the number of duplicates within the products.
// It has the following:
// names: string array of size n, where namesi denotes the name of the ith product
// prices: int array of size n, where pricesi denotes the price of the ith product
// weights: int array of size n, where weightsi denotes the weight of the ith product
// Constraints
// · 1 ≤ n ≤ 105
// · namesi is non-empty, has at most 10 characters, and all its characters are lowercase english letters
// · 1 ≤ pricesi, weightsi ≤ 1000
// Input Format Format for Custom Testing
// Input from stdin will be processed as follows and passed to the function:
// In the first line, there is a single integer n.
// Then, n lines follow. In the ith of them, there is a single string namesi
// In the next line, there is a single integer n.
// Then, n lines follow. In the ith of them, there is a single integer pricesi
// In the next line, there is a single integer n.
// Then, n lines follow. In the ith of them, there is a single integer weightsi
// Sample Case 0
// Sample Input
// 5
// ball
// box
// ball
// ball
// box
// 5
// 2
// 2
// 2
// 2
// 2
// 5
// 1
// 2
// 1
// 1
// 3
// Sample Output
// 2
// Explanation
// There are 5 products. All 3 balls are the same because they have same names, prices, and weights, so they contribute 2 duplicates.
// Two other products are boxes, and they are different because they have different weights.
#include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
char name[n][10];
int p[n],w[n],c=0;
for(int i=0;i<n;i++)
scanf("%s",name[i]);
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&p[i]);
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&w[i]);
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if((strcmp(name[i],name[j])==0) && (p[i]==p[j]) && (w[i]==w[j]))
{
c++;
break;
}
}
}
printf("%d",c);
}