1 /*
2 * File: D.cpp
3 * Author: GongZhi
4 * Problem:
5 * Created on 2009年7月27日, 上午10:00
6 */
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <queue>
15 using namespace std;
16
17 /*
18 *
19 */
20 int data[2][11000];
21
22 int main() {
23 srand(time(NULL));
24 int n, m, i, f, k, p, j;
25 int t0, t1;
26 int t, sumt;
27 int sum0, sum1;
28 double ans;
29 while (scanf("%d%d", &n, &m) != EOF) {
30 sum0 = 0;
31 sum1 = 0;
32 for (i = 0; i < n; i++) {
33 scanf("%d%d", &data[0][i], &data[1][i]);
34 sum0 += data[0][i];
35 sum1 += data[1][i];
36 }
37 if (sum0 > sum1)f = 0;
38 else f = 1;
39 p = n / 2;
40 sum0 = 0;
41 sum1 = 0;
42 for (i = 0; i < p; i++)sum0 += data[f][i];
43 for (i = p; i < n; i++)sum1 += data[f][i];
44 sumt = sum0 - sum1;
45 if (sumt < 0)sumt = -sumt;
46 // printf("%d %d %d\n",sum0,sum1,sumt);
47 for (k = 0; k <= 1000000; k++) {
48 i = rand() % p;
49 j = rand() % p + p;
50 t0 = sum0 - data[f][i] + data[f][j];
51 t1 = sum1 + data[f][i] - data[f][j];
52 t = t0 - t1;
53 if (t < 0)t = -t;
54 sumt = sum0 - sum1;
55 if (sumt < 0)sumt = -sumt;
56 if (t < sumt) {
57 sumt = t;
58 sum0 = t0;
59 sum1 = t1;
60 t = data[f][i];
61 data[f][i] = data[f][j];
62 data[f][j] = t;
63 }
64 }
65 if (sum0 < sum1)sumt = sum0;
66 else sumt = sum1;
67 // printf("%d\n",sumt);
68 if (2 * sumt <= p * m)printf("No solution\n");
69 else {
70 if (!f)printf("W ");
71 else printf("B ");
72 ans = ((double) (sumt * 100.0)) / (p * m);
73 printf("%.2f\n", ans);
74 }
75 }
76 return 0;
77 }
78
79
80