Career memoirs completely touched. . . Anyway, nothing to see people (
A few days to give lectures on popular group god Ben wondering do something universal problem, then almost burst ,, hammer
Looking questions on luogu https://www.luogu.org/problemnew/show/P5017 , not posted
Consider first if two people before and after the waiting time by more than $ m $ (round trip time), it must not have to wait, because the middle can send trip. So we found the $ 4e6 $ of $ t_i $ certain range of data useless ...... but certainly time to sort this visit.
So this will certainly be a dp with f [i] [j] represents the individual all-ago i sent away, and the last bus waited to make $ i $ $ j $ minutes ago total of $ i $ individuals such as how long. Then f [i] [j] may be transferred to the f [k] [take the next bus time - $ t_k $], including $ k $ denotes the person before sending the next one to $ k $. Departure time of this time is the next train to go $ f [i] [j] $ represented $ + m $ and $ $ xtk take max. Spend more time with the prefix and maintenance on the line. First I did not consider the second dimension, too dishes. .
Code running very slow, constant big people food
#include<bits/stdc++.h> using namespace std; const int N=510; const int inf=0x3f3f3f3f; int f[N][N],a[N],s[N]; int main(){ memset(f,63,sizeof f); int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+n+1); for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i]; f[0][0]=0;a[0]=-inf; for(int i=0;i<=n;i++){ for(int k=i+1;k<=n;k++){ for(int j=0;j<m;j++){ int t=max(a[k],a[i]+j+m); f[k][t-a[k]]=min(f[k][t-a[k]],f[i][j]+t*(k-i)-(s[k]-if])); } } } Int years = inf; for ( int j = 0 ; j <m; j ++ ) years = min (years, f [n] [j]); cout << age << endl; }