crystal
#include<bits/stdc++.h>
#define z long long
using namespace std;z a[500000],n,m,y=1,l=0,r=0,h=0;int main(){freopen("crystal.in","r",stdin);freopen("crystal.out","w",stdout);cin>>n>>m;for(z i=0;i<n;i++)cin>>a[i];sort(a,a+n);while(r<n){while(h>m)h-=a[r]-a[l++];y=max(y,(++r)-l);h+=(a[r]-a[r-1])*(r-l);}cout<<y;return 0;}subway
#include<bits/stdc++.h>
using namespace std;
#define int long long
int w[500001], f[501][501];
struct edge{
int p, val;
edge(int P, int VAL){
p = P;
val = VAL;
}
};
vector<edge>g[500001];
signed main(){
freopen("subway.in", "r", stdin);
freopen("subway.out", "w", stdout);
int c, n, m, d, q, k, x, y;
cin >> c >> n >> m >> d >> q;
for(int i = 1; i <= m; i++)scanf("%lld", w + i);
memset(f, 0x3f, sizeof(f));
for(int i = 1; i <= n; i++){
f[i][i] = 0;
cin >> k;
while(k--){
scanf("%lld%lld", &x, &y);
g[x].push_back(edge(i, y));
}
}
for(int i = 1; i <= m; i++){
k = g[i].size();
for(int a = 0; a < k; a++){
for(int b = a + 1; b < k; b++){
x = g[i][a].p;
y = g[i][b].p;
f[x][y] = f[y][x] = min(f[x][y], g[i][a].val + g[i][b].val);
}
}
}
for(int l = 1; l <= n; l++)for(int i = 1; i <= n; i++)for(int j = 1; j <= n; j++)f[i][j] = min(f[i][j], f[i][l] + f[l][j]);
while(q--){
cin >> x >> y;
k = 0x7f7f7f7f7f7f7f7fll;
for(int i = 0; i < g[x].size(); i++)for(int j = 0; j < g[y].size(); j++)k = min(k, f[g[x][i].p][g[y][j].p] + g[x][i].val + g[y][j].val);
cout << k + w[x] + w[y] + 1 << "\n";
}
return 0;
}migrate
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[2000002], f[2000001], dp[2000001][2];
signed main(){
freopen("migrate.in", "r", stdin);
freopen("migrate.out", "w", stdout);
int c, t, n, d, ans;
cin >> c >> t;
while(t--){
cin >> n >> d;
for(int i = 1; i <= n; i++)scanf("%lld", a + i);
a[n + 1] = 0x7f7f7f7f7f7f7f7fll;
for(int i = 1; i <= n; i++)a[i] = upper_bound(a + i, a + n + 2, a[i] + d) - a - 1;
ans = dp[n][0] = dp[n][1] = 0;
for(int i = n - 1; i >= 1; i--){
if(a[i] == i)dp[i][0] = dp[i][1] = 0;
else if(a[a[i] - 1] == a[a[i]]){
dp[i][0] = 0;
dp[i][1] = a[a[i] - 1] - max(a[a[i] - 2], a[i]);
if(a[a[i] - 2] < a[a[i]])dp[i][1] += dp[a[i]][0];
}else{
dp[i][0] = dp[a[i]][0] + a[a[i]] - max(a[a[i] - 1], a[i]);
dp[i][1] = a[a[a[i]] - 1] - max(a[max(a[a[i]] - 2, a[a[i] - 1])], a[a[i]]) + a[a[i] - 1] - max(a[a[i] - 2], a[i]);
if(a[a[a[i] - 1]] < a[a[a[i]]])dp[i][1] += dp[a[i]][1] - a[a[a[i]] - 1] + max(a[a[a[i]] - 2], a[a[i]]);
}
ans += dp[i][1];
}
cout << ans << "\n";
}
return 0;
}hub
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("hub.in", "r", stdin);
freopen("hub.out", "w", stdout);
cout << "luogu 1054319 / pgr rks16.64 / ban tuiyi / orz%%%";
cout << "Echo Tree, Yum Yum Yum, Echo Tree For Everyone, Echo Tree, Yum Yum Yum, An Echo A Day Keeps Doctors Away";
cout << "//freopen()";
cout << "About the C++ / Implexroll / Evanescence / Entrance to the Csp / Exoplanetary Migrate / True Home, True Luogu (Rework) / I'm tree / E tree cho / ? / Desultory Samples / Accepted / What do you want more than a 300pts ending?";
cout << "-- the fw ljx 2026.10.31 18:25";
return 0;
}