Submission #222192

#TimeUsernameProblemLanguageResultExecution timeMemory
222192kartel새로운 문제 (COCI19_akvizna)C++14
130 / 130
454 ms7544 KiB
#include <bits/stdc++.h> #define in(x) freopen(x,"r",stdin) #define out(x) freopen(x,"w",stdout) #define F first #define S second #define pb push_back #define M ll(998244353) #define inf ll(2e9+7) #define N ll(100500) #define sz(x) x.size() //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("O3") //#pragma GCC optimize("Ofast") #define el '\n' using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> os; ld f[N], b[N]; ll n, m, i, j, kol, sz, num[N], pr, K; ld cht[N], k[N]; void AddInCHT(int i) { ld x; while (1) { pr = num[sz]; x = (b[pr] - b[i]) / (k[i] - k[pr]); // cerr << x << el; if (x - cht[sz] > 1e-18) break; sz--; } sz++; cht[sz] = x; num[sz] = i; } int ch(ld X) { sz = 1; cht[sz] = -1e18; num[sz] = n; b[n] = 0; f[n] = 0; k[n] = 1.0 / ld(n); for (i = n - 1; i >= 0; i--) { int l = 1; int r = sz; while (l < r) { int md = (l + r + 1) >> 1; ld x = cht[md]; if (x + ld(i) < 1e-18) l = md; else r = md - 1; } K = num[l]; f[i] = f[K] + 1; b[i] = b[K] + 1 - ld(i) * k[K] + X; k[i] = ld(1) / ld(i); AddInCHT(i); } return f[0]; } int main() { // in("input.txt"); // out("output.txt"); ios_base::sync_with_stdio(false); iostream::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; ld l = 0; ld r = 1e12; while (r - l > 1e-13) { ld md = (l + r) * 0.5; if (ch(-md) > m) l = md + 1e-13; else r = md; } ch(-l); cout << setprecision(9) << fixed << b[0] + l * ld(m); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...