用户输出
4
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#21198 | #1031. JM的特快列车 | Accepted | 100 | 490 ms | 760 K | C++ 17 / 730 B | 自动化82-郭筠陶 | 2020-01-22 23:51:47 |
#include <bits/stdc++.h>
using namespace std;
bool check(int minDist);
int m, n, k;
vector<int> points;
int main() {
cin >> n >> m >> k;
points = vector<int>(n + 1);
for (int i = 0; i < n; i++) cin >> points.at(i);
points.at(n) = k;
sort(points.begin(), points.end());
int left = 0, right = 1e9, res = 0;
while (left <= right) {
int mid = (left + right) / 2;
if (check(mid)) {
left = mid + 1;
res = mid;
} else {
right = mid - 1;
}
}
cout << res;
}
bool check(int minDist) {
int prev = 0, cnt = 0;
for (int i = 0; i <= n; i++) {
if (points.at(i) - prev < minDist) {
cnt++;
} else {
prev = points.at(i);
}
}
return (cnt <= m);
}
95081 77335 568254347
160731933 121592942 545359032 42372661 94548234 31387055 297203963 120233938
<930969 bytes omitted>
用户输出
25967
系统信息
Exited with return code 0
93202 26371 640243133
544564116 20205828 399307350 600697625 98046473 248585032 150738566 19380659
<915056 bytes omitted>
用户输出
2706
系统信息
Exited with return code 0
98726 15172 4863256
4061736 2523417 2966284 1702310 1537399 4510660 4013440 4354876 2840737 4397394
<767088 bytes omitted>
用户输出
9
系统信息
Exited with return code 0
100000 99862 197697696
189350415 146517714 171890535 104293377 143894247 186136108 163590632 166302
<943029 bytes omitted>
用户输出
1420180
系统信息
Exited with return code 0
100000 142 25917879
25050015 18738442 17905039 7617439 1530367 10773344 8382003 14486136 11569183 2
<856866 bytes omitted>
用户输出
1
系统信息
Exited with return code 0
100000 0 409108430
185938952 21819912 310245988 320735736 37814393 158165858 368886326 407468247 43
<971434 bytes omitted>
用户输出
1
系统信息
Exited with return code 0
100000 100000 595536117
374138900 81845477 282044690 198472228 155427374 591666576 348669485 576466
<979298 bytes omitted>
用户输出
595536117
系统信息
Exited with return code 0
100000 69297 100001
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 3
<588817 bytes omitted>
用户输出
3
系统信息
Exited with return code 0
100000 85178 1000000000
2 4 6 8 9 10 12 14 16 18 19 20 22 23 24 25 27 29 31 32 33 35 36 37 39 41 42
<625941 bytes omitted>
用户输出
9
系统信息
Exited with return code 0
100000 14352 1000000000
1 2 3 5 7 8 10 12 13 15 16 18 20 21 23 25 26 27 29 31 32 33 35 37 38 40 41
<625955 bytes omitted>
用户输出
1
系统信息
Exited with return code 0
100000 99999 100031
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 3
<588817 bytes omitted>
用户输出
50015
系统信息
Exited with return code 0
100000 45195 916842072
4 5 9 11 12 13 14 17 21 25 27 30 34 36 40 42 45 46 49 50 54 57 61 62 64 65 6
<655452 bytes omitted>
用户输出
3
系统信息
Exited with return code 0
100000 2321 623818276
4 7 11 14 16 20 24 28 29 31 33 37 41 44 47 51 52 55 59 63 65 67 68 70 74 76 7
<655432 bytes omitted>
用户输出
1
系统信息
Exited with return code 0
100000 63443 223616492
2 4 6 9 10 14 16 20 23 25 28 29 33 36 38 40 41 42 44 45 49 51 54 58 59 61 64
<655623 bytes omitted>
用户输出
5
系统信息
Exited with return code 0