[CodeForces] 311B 题解

链接

problem: https://codeforces.com/problemset/problem/311/B

status: https://codeforces.com/problemset/submission/311/163441918

题解

disi=j=1iDjtime={sort(TidisHi)}pretime=j=1itimeidis_i = \sum_{j = 1}^i D_j \newline time = \{sort(T_i - dis_{H_i})\} \newline pretime = \sum{j = 1}^i time_i \newline

fi=fj+(ij)timei(pretimeipretimej)gi=gj+(ij)timeires=gitimeif_i = f_j + (i - j) * time_i - (pretime_i - pretime_j) \newline \newline g_i = g_j + (i - j) * time_i \newline res = g_i - \sum time_i \newline

ff gg 两种不同的解法, 有时候只有 gg 能够使用 (如以时间为 ii) .