1 

 

#include<stdio.h>
 2 #include<string.h>
 3 int l, k, j, i, p;
 4 int tim[5] = { 0 };
 5 int tim_sum[120][5] = { 0 };
 6 int ans[120] = { 0 };
 7 int table[120][5] = { 0 };
 8 int sum(int i, int val) {
 9     int ans = 0;
10     switch (i)
11     {
12     case 0: {
13         ans += 500 - 2 * val;
14         break;
15     }case 1: {
16         ans += 1000 - 4 * val;
17         break;
18     }case 2: {
19         ans += 1500 - 6 * val;//250
20         break;
21     }case 3: {
22         ans += 2000 - 8 * val;//250
23         break;
24     }case 4: {
25         ans += 2500 - 10 * val;
26         break;
27     }
28     default:
29         break;
30     }
31     return ans;
32 }
33 int ix = 0;
34 
35 void sequence() {
36     int label = 0;
37     for (i = 0; i < 5; i++) {
38         for (j = 0; j < 5; j++) {
39             if (j == i) continue;
40             for (k = 0; k < 5; k++) {
41                 if (k == i || k == j) continue;
42                 for (l = 0; l < 5; l++) {
43                     if (l == i || l == j || l == k) continue;
44                     for (p = 0; p < 5; p++) {
45                         if (p == i || p == j || p == k || p == l) continue;
46                         table[label][0] = i;
47                         table[label][1] = j;
48                         table[label][2] = k;
49                         table[label][3] = l;
50                         table[label][4] = p;
51                         label++;
52                     }
53 
54                 }
55 
56             }
57 
58         }
59     }
60 }
61 void time() {
62     for (int i = 0; i < 120; i++) {
63         int diff = 0;
64         for (int j = 0; j < 5; j++) {
65             diff += tim[table[i][j]];
66             tim_sum[i][j] = diff;
67         }
68     }
69 }
70 int main() {
71     int n;
72     scanf("%d", &n);
73     for (int q = 0; q < n; q++) {
74         for (int i = 0; i < 5; i++) {
75             scanf("%d", &tim[i]);//输入每一道题的时间
76         }
77         memset(tim_sum, 0, 20);
78         sequence();//所有的顺序弄出来
79         time();//算出时间的总和
80 
81         for (int i = 0; i < 120; i++) {
82             int res = 0;
83             for (int j = 0; j < 5; j++) {
84                 if(tim_sum[i][j]<=120)
85                 res += sum(table[i][j],tim_sum[i][j]);
86             }
87             ans[i] = res;
88         }
89     
90         /*printf("\n%d\n", index);*/
91         int max = -10000000;
92         for (int i = 0; i < 120; i++) {
93             if (ans[i] > max) max = ans[i];
94         }
95         if (max < 0) max = 0;
96         printf("%d\n", max);
97     }
98     return 0;
99 }