Submission #478886

#TimeUsernameProblemLanguageResultExecution timeMemory
478886rainboy새로운 문제 (COCI19_akvizna)C11
130 / 130
89 ms1872 KiB
#include <stdio.h> #define N 100000 double dp[N + 1]; int kk[N + 1], n; double cross(int i, int j, int k) { return (j - i) * (dp[k] - dp[i]) - (k - i) * (dp[j] - dp[i]); } double eval(int i, double x) { return -i * x + dp[i]; } void solve(double c) { static int qu[N + 1]; int i, head, cnt; dp[0] = 0, kk[0] = 0; head = cnt = 0; qu[head + cnt++] = 0; for (i = 1; i <= n; i++) { while (cnt >= 2 && eval(qu[head], (double) 1 / i) < eval(qu[head + 1], (double) 1 / i)) head++, cnt--; dp[i] = eval(qu[head], (double) 1 / i) + 1 - c, kk[i] = kk[qu[head]] + 1; while (cnt >= 2 && cross(qu[head + cnt - 2], qu[head + cnt - 1], i) >= 0) cnt--; qu[head + cnt++] = i; } } int main() { int k, r; double lower, upper; scanf("%d%d", &n, &k); lower = 0, upper = 1; for (r = 0; r < 60; r++) { double c = (lower + upper) / 2; solve(c); if (kk[n] <= k) upper = c; else lower = c; } solve(upper); printf("%.9f\n", dp[n] + k * upper); return 0; }

Compilation message (stderr)

akvizna.c: In function 'main':
akvizna.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
#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...