A - Airport Coffee

留坑。

 

B - Best Relay Team

枚举首棒

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 #define N 510
 6 #define INF 0x3f3f3f3f
 7 
 8 struct node
 9 {
10     string name;
11     double v1, v2;
12     inline void scan()
13     {
14         cin >> name >> v1 >> v2;
15     }
16     inline bool operator < (const node &r) const
17     {
18         return v2 < r.v2;
19     }
20 }arr[N];
21 
22 int n;
23 double Min;
24 string ans[4], tmpname[4];
25 
26 int main()
27 {
28     cin.tie(0);
29     cout.tie(0);
30     ios::sync_with_stdio(false);
31     cin >> n;
32     for (int i = 1; i <= n; ++i) arr[i].scan();
33     sort(arr + 1, arr + 1 + n);
34     Min = INF * 1.0;
35     for (int i = 1; i <= n; ++i)
36     {
37         double tmp = 0;
38         tmp += arr[i].v1;
39         tmpname[0] = arr[i].name;
40         for (int j = 1, cnt = 1; j <= n && cnt < 4; ++j)
41         {
42             if (i == j) continue;
43             tmp += arr[j].v2;
44             tmpname[cnt++] = arr[j].name;
45         }
46         if (tmp < Min)
47         {
48             Min = tmp;
49             for (int j = 0; j < 4; ++j) ans[j] = tmpname[j];
50         }
51     }
52     cout << setiosflags(ios::fixed) << setprecision(2) << Min << endl;
53     for (int i = 0; i < 4; ++i) cout << ans[i] << endl;
54     return 0;
55 }
View Code

相关文章:

  • 2021-05-22
  • 2021-09-17
  • 2021-11-15
  • 2021-09-22
  • 2021-08-14
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2021-09-25
  • 2021-11-24
  • 2021-10-15
  • 2021-10-24
相关资源
相似解决方案