跳到主内容
paste
bin
.ca
type · paste · share
⌘
K
系列
bin 系列
pastebin.ca
中心
Share text and code with expiry and privacy controls.
imagebin.ca
Upload and share images with direct links.
filebin.ca
Drop a file and get a shareable link.
notebin.ca
Write Markdown notes with durable links.
turl.ca
Short, reputation-checked links.
attn.ca
Notifications and alerts for your services.
voicebin.ca
Record and share short voice clips.
dnsbin.ca
Inspect DNS and debug records.
文档
登录
?
← 返回文本
›
编辑 / 分支
无标题文本
#2HWh3m9LLZ
public / public
新版本
匿名
已创建 22 hours ago
过期于 6 days
1.3 KB
语法:
text
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
新版本
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
标题(可选)
文件名
语法
text
text
bash
c
cpp
css
diff
dockerfile
go
html
ini
java
javascript
json
kotlin
lua
makefile
markdown
nginx
php
python
ruby
rust
shellscript
sql
swift
toml
typescript
xml
yaml
可见性
公开动态
访问
public
过期
7 天
10 分钟
1 小时
1 天
7 天
30 天
90 天
自定义…
自定义过期
变更备注
(可选)
此文本会显示在公开动态中。如果只想通过链接分享,请更改可见性。
创建新版本
取消
粘贴或输入…
#include <bits/stdc++.h> using namespace std; #define int long long // 数据范围大,开long long防溢出 int n, L; vector<int> arr; signed main() { // 快读快写 ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr); cin >> n >> L; int m = L / 2; // m是半圆长度,传送的距离 for (int i = 0; i < n; i++) { int a; cin >> a; // opp是a的正对(传送后)的位置 int opp = a + m; if (opp >= L) opp -= L; // 将一对对径点压缩成[0,m)内的代表点,取较小的那个 arr.push_back(min(a, opp)); } sort(arr.begin(), arr.end()); // 去重:相同压缩点只保留一份 arr.erase(unique(arr.begin(), arr.end()), arr.end()); int k = arr.size(); // 只有一类点,站原地直接传送就能全部访问,时间0 if (k == 1) { cout << 0 << endl; return 0; } int gap = 0; // 计算排序后相邻点之间的空隙 for (int i = 1; i < k; i++) { gap = max(gap, arr[i] - arr[i-1]); } // 环形:最后一个点回到第一个点的空隙 int ci = m - (arr.back() - arr[0]); gap = max(gap, ci); // m是总长度,减去最大空隙就是最少需要行走的距离 int ans = m - gap; cout << ans << endl; return 0; }