QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#83405#2884. 切切糕ZBSTChen#WA 4ms43076kbC++14684b2023-03-01 19:25:062023-03-01 19:25:10

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-01 19:25:10]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:43076kb
  • [2023-03-01 19:25:06]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <queue>

const int N = 2505;

int a[N], s[N];
double dp[N][N];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    std::sort(a + 1, a + n + 1, std::greater<int>());
    for (int i = 1; i <= n; ++i) {
        s[i] = s[i - 1] + a[i];
        dp[i][0] = s[i];
        dp[i][i] = s[i] / 2.0;
        for (int j = 1; j < i; ++j) {
            dp[i][j] = std::max(0.0, a[i] - (dp[i - 1][j - 1] - dp[i - 1][j])) / 2 + dp[i - 1][j - 1];
            // printf("%d %d %6lf\n", i, j, dp[i][j]);
        }
    }
    printf("%.6lf\n", dp[n][m]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 1660kb

input:

1 1
10

output:

5.000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10 8
1 2 3 1 2 2 1 3 3 2

output:

10.035156

result:

ok found '10.0351560', expected '10.0351562', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 4ms
memory: 43076kb

input:

2500 1
1 1 2 1 4 1 5 1 2 2 3 4 2 3 4 3 4 1 4 5 3 5 4 4 1 3 3 3 5 5 5 3 2 2 3 2 3 2 1 1 5 4 2 1 3 4 3 4 2 3 1 1 2 2 2 4 3 1 1 4 2 2 4 3 5 4 2 3 1 1 4 3 3 4 3 1 2 1 1 2 2 4 4 3 3 2 5 4 2 4 5 4 5 3 1 5 1 3 3 1 1 3 5 3 5 1 1 4 3 5 2 4 1 5 2 1 3 3 1 1 5 2 1 3 4 1 2 4 2 2 2 3 5 1 1 3 1 1 5 1 2 3 3 5 4 4 5...

output:

7446.000000

result:

wrong answer 1st numbers differ - expected: '7442.0000000', found: '7446.0000000', error = '0.0005375'