// Nikita Golikov, 2023 #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; #ifdef GOLIKOV #include "/Users/golikovnik/contests/debug.h" #else #define debug(...) ; #endif template bool smin(A& x, B&& y) { if (y < x) { x = y; return true; } return false; } template bool smax(A& x, B&& y) { if (x < y) { x = y; return true; } return false; } int main() { #ifdef GOLIKOV assert(freopen("in", "rt", stdin)); auto _clock_start = chrono::high_resolution_clock::now(); #endif ios::sync_with_stdio(false); cin.tie(nullptr); int n, p; cin >> n >> p; using ld = double; vector a(n); ld const pi = acos(-1.0); for (auto& x : a) { cin >> x; x /= 360; x *= 2 * pi; } vector score(n, vector(n)); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { score[i][j] = sin(a[j] - a[i]); score[j][i] = sin(a[i] - a[j] + 2 * pi); } } ld ans = 0; ld const INF = -1e40; for (int s = 0; s < n; ++s) { vector dp(p + 1, vector(n + 1, INF)); dp[1][s] = 0; for (int t = s + 1; t < n; ++t) { int fromCnt = min(p - 1, t - s); for (int cnt = fromCnt; cnt >= 1; --cnt) { for (int wh = s; wh < t; ++wh) { smax(dp[cnt + 1][t], dp[cnt][wh] + score[wh][t]); } } } for (int cnt = 3; cnt <= p; ++cnt) { for (int x = s + 1; x < n; ++x) { smax(ans, dp[cnt][x] + score[x][s]); } } } cout << setprecision(12) << fixed << ans * 500000 << '\n'; #ifdef GOLIKOV cerr << "Executed in " << chrono::duration_cast( chrono::high_resolution_clock::now() - _clock_start).count() << "ms." << endl; #endif return 0; }