提交时间:2023-11-09 13:25:25
运行 ID: 109499
# include <iostream> using namespace std ; int a [114514] , l , n , m , lb , ub ; bool check ( long long x ) { int p = a [0] , sum = 0 ; for ( int i = 1 ; i <= n + 1 ; i ++ ) { if ( a [i] - p < x ) { sum ++ ; } else { p = a [i] ; } } return sum <= m ; } int main ( ) { cin >> l >> n >> m ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> a [i] ; } a [n + 1] = l ; int ub = l + 1 ; while ( ub > lb ) { int mid = ( ub + lb ) / 2.0 ; if ( check ( mid ) ) { lb = mid ; } else { ub = mid ; } } cout << lb << endl ; return 0 ; }