-
Notifications
You must be signed in to change notification settings - Fork 0
/
1002.c
42 lines (37 loc) · 833 Bytes
/
1002.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
#include <stdio.h>
int main()
{
int n, a, i, j, cnt = 0, max = 0;
double A[1001][2] = {0}, b;
for (i = 0; i < 2; i++)
{
scanf("%d", &n);
for (j = 0; j < n; j++)
{
scanf("%d %lf", &a, &b);
A[a][1] += b;
A[a][0]++;
if (A[a][0] == 1 && (b >= 0.05 || b <= -0.05))
{
cnt++;
}
else if (A[a][0] > 1 && A[a][1] < 0.05 && A[a][1] > -0.05)
{
cnt--;
}
if (max < a)
{
max = a;
}
}
}
printf("%d", cnt);
for (i = max; i >= 0; i--)
{
if (A[i][0] != 0 && (A[i][1] >= 0.05 || A[i][1] <= -0.05))
{
printf(" %d %.1lf", i, A[i][1]);
}
}
return 0;
}