8
8
9
9
<!-- problem:start -->
10
10
11
- # [ 3601. Find Drivers with Improved Fuel Efficiency ] ( https://leetcode.cn/problems/find-drivers-with-improved-fuel-efficiency )
11
+ # [ 3601. 寻找燃油效率提升的驾驶员 ] ( https://leetcode.cn/problems/find-drivers-with-improved-fuel-efficiency )
12
12
13
13
[ English Version] ( /solution/3600-3699/3601.Find%20Drivers%20with%20Improved%20Fuel%20Efficiency/README_EN.md )
14
14
15
15
## 题目描述
16
16
17
17
<!-- description:start -->
18
18
19
- <p >Table: <code >drivers</code ></p >
19
+ <p >表: <code >drivers</code ></p >
20
20
21
21
<pre >
22
22
+-------------+---------+
@@ -25,11 +25,11 @@ tags:
25
25
| driver_id | int |
26
26
| driver_name | varchar |
27
27
+-------------+---------+
28
- driver_id is the unique identifier for this table.
29
- Each row contains information about a driver.
28
+ driver_id 是这张表的唯一主键。
29
+ 每一行都包含一个司机的信息。
30
30
</pre >
31
31
32
- <p >Table: <code >trips</code ></p >
32
+ <p >表: <code >trips</code ></p >
33
33
34
34
<pre >
35
35
+---------------+---------+
@@ -41,31 +41,32 @@ Each row contains information about a driver.
41
41
| distance_km | decimal |
42
42
| fuel_consumed | decimal |
43
43
+---------------+---------+
44
- trip_id is the unique identifier for this table.
45
- Each row represents a trip made by a driver, including the distance traveled and fuel consumed for that trip.
44
+ trip_id 是这张表的唯一主键。
45
+ 每一行表示一名司机完成的一次行程,包括该次行程行驶的距离和消耗的燃油量。
46
46
</pre >
47
47
48
- <p >Write a solution to find drivers whose <strong >fuel efficiency has improved </strong > by <strong >comparing </strong > their average fuel efficiency in the <strong > first half< /strong > of the year with the <strong >second half </strong > of the year. </p >
48
+ <p >编写一个解决方案,通过 <strong >比较 </strong > 司机在 <strong >上半年 </strong > 和 <strong >下半年</ strong > 的 < strong >平均燃油效率< /strong > 来找出 <strong >燃油效率有所提高 </strong > 的司机。 </p >
49
49
50
50
<ul >
51
- <li>Calculate <strong>fuel efficiency</strong> as < code>distance_km / fuel_consumed</code> for <strong>each </strong> trip </li>
52
- <li><strong>First half </strong>: January to June, <strong>Second half </strong>: July to December </li>
53
- <li>Only include drivers who have trips in <strong>both halves</strong> of the year </li>
54
- <li>Calculate the <strong>efficiency improvement</strong> as (< code>second_half_avg - first_half_avg</code>) </li>
55
- <li><strong>Round </ strong>all<strong> < /strong>results<strong> </strong>to<strong> <code>2</code> </strong>decimal<strong> </strong>places </li>
51
+ <li>通过 < code>distance_km / fuel_consumed</code> 计算 <strong>每次 </strong> 行程的 <strong>燃油效率</strong>。 </li>
52
+ <li><strong>上半年: </strong>一月到六月, <strong>下半年: </strong>七月到十二月 </li>
53
+ <li>只包含在上半年和下半年都有行程的司机 </li>
54
+ <li>通过(< code>second_half_avg - first_half_avg</code>)计算 <strong>提升效率</strong>。 </li>
55
+ <li>将所有结果 < strong>四舍五入< /strong> 到小数点后 <code>2</code> 位 </li>
56
56
</ul >
57
57
58
- <p >Return < em >the result table ordered by efficiency improvement in < strong >descending </strong > order, then by driver name in <strong >ascending </strong > order</ em >. </p >
58
+ <p >返回结果表按提升效率 & nbsp ; < strong >降序 </strong > 排列,然后按司机姓名 <strong >升序 </strong > 排列。 </p >
59
59
60
- <p >The result format is in the following example. </p >
60
+ <p >结果格式如下所示。 </p >
61
61
62
62
<p >  ; </p >
63
- <p ><strong class =" example " >Example:</strong ></p >
63
+
64
+ <p ><strong class =" example " >示例:</strong ></p >
64
65
65
66
<div class =" example-block " >
66
- <p ><strong >Input: </strong ></p >
67
+ <p ><strong >输入: </strong ></p >
67
68
68
- <p >drivers table: </p >
69
+ <p >drivers 表: </p >
69
70
70
71
<pre class =" example-io " >
71
72
+-----------+---------------+
@@ -79,7 +80,7 @@ Each row represents a trip made by a driver, including the distance traveled and
79
80
+-----------+---------------+
80
81
</pre >
81
82
82
- <p >trips table: </p >
83
+ <p >trips 表: </p >
83
84
84
85
<pre class =" example-io " >
85
86
+---------+-----------+------------+-------------+---------------+
@@ -100,7 +101,7 @@ Each row represents a trip made by a driver, including the distance traveled and
100
101
+---------+-----------+------------+-------------+---------------+
101
102
</pre >
102
103
103
- <p ><strong >Output: </strong ></p >
104
+ <p ><strong >输出: </strong ></p >
104
105
105
106
<pre class =" example-io " >
106
107
+-----------+---------------+------------------+-------------------+------------------------+
@@ -111,39 +112,39 @@ Each row represents a trip made by a driver, including the distance traveled and
111
112
+-----------+---------------+------------------+-------------------+------------------------+
112
113
</pre >
113
114
114
- <p ><strong >Explanation: </strong ></p >
115
+ <p ><strong >解释: </strong ></p >
115
116
116
117
<ul >
117
118
<li><strong>Alice Johnson (driver_id = 1):</strong>
118
119
119
120
<ul>
120
- <li>First half trips (Jan-Jun): Feb 15 (120.5/10.2 = 11.81), Mar 20 (200.0/16.5 = 12.12)</li>
121
- <li>First half average efficiency: (11.81 + 12.12) / 2 = 11.97</li>
122
- <li>Second half trips (Jul-Dec): Aug 10 (150.0/11.0 = 13.64), Sep 25 (180.0/12.5 = 14.40)</li>
123
- <li>Second half average efficiency: (13.64 + 14.40) / 2 = 14.02</li>
124
- <li>Efficiency improvement: 14.02 - 11.97 = 2.05</li>
121
+ <li>上半年行程(一月到六月): Feb 15 (120.5/10.2 = 11.81), Mar 20 (200.0/16.5 = 12.12)</li>
122
+ <li>上半年平均效率: (11.81 + 12.12) / 2 = 11.97</li>
123
+ <li>下半年行程(七月到十二月): Aug 10 (150.0/11.0 = 13.64), Sep 25 (180.0/12.5 = 14.40)</li>
124
+ <li>下半年平均效率: (13.64 + 14.40) / 2 = 14.02</li>
125
+ <li>效率提升: 14.02 - 11.97 = 2.05</li>
125
126
</ul>
126
127
</li>
127
128
<li><strong>Bob Smith (driver_id = 2):</strong>
128
129
<ul>
129
- <li>First half trips: Jan 10 (100.0/9.0 = 11.11), Apr 15 (250.0/22.0 = 11.36)</li>
130
- <li>First half average efficiency: (11.11 + 11.36) / 2 = 11.24</li>
131
- <li>Second half trips: Oct 5 (200.0/15.0 = 13.33)</li>
132
- <li>Second half average efficiency: 13.33</li>
133
- <li>Efficiency improvement: 13.33 - 11.24 = 2.09</li>
130
+ <li>上半年行程: Jan 10 (100.0/9.0 = 11.11), Apr 15 (250.0/22.0 = 11.36)</li>
131
+ <li>上半年平均效率: (11.11 + 11.36) / 2 = 11.24</li>
132
+ <li>下半年行程: Oct 5 (200.0/15.0 = 13.33)</li>
133
+ <li>下半年平均效率: 13.33</li>
134
+ <li>效率提升: 13.33 - 11.24 = 2.09</li>
134
135
</ul>
135
136
</li>
136
- <li><strong>Drivers not included: </strong>
137
+ <li><strong>未包含的司机: </strong>
137
138
<ul>
138
- <li>Carol Davis (driver_id = 3): Only has trips in first half (Mar, May) </li>
139
- <li>David Wilson (driver_id = 4): Only has trips in second half (Jul, Nov) </li>
140
- <li>Emma Brown (driver_id = 5): Only has trips in first half (Feb) </li>
139
+ <li>Carol Davis (driver_id = 3):只有上半年的行程(三月,五月) </li>
140
+ <li>David Wilson (driver_id = 4):只有下半年的行程(七月,十一月) </li>
141
+ <li>Emma Brown (driver_id = 5):只有上半年的行程(二月) </li>
141
142
</ul>
142
143
</li>
143
144
144
145
</ul >
145
146
146
- <p >The output table is ordered by efficiency improvement in descending order then by name in ascending order. </p >
147
+ <p >输出表按提升效率降序排列,然后按司机名字升序排列。 </p >
147
148
</div >
148
149
149
150
<!-- description:end -->
0 commit comments