QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#453857#8524. Weather Forecastucup-team1525#WA 0ms3992kbC++20884b2024-06-24 13:26:522024-06-24 13:26:52

Judging History

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

  • [2024-06-24 13:26:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3992kb
  • [2024-06-24 13:26:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 50;
using db = double;

int n, k;
int s[N];

bool check(db mid) {
    multiset<db> ss;
    ss.insert(0);
    db las = s[n] - mid * n;
    for (int i = 1; i < n; i++) {
        db x = s[i] - mid * i;
        if (x < 0) continue;
        if (x > las) continue;
        auto it = ss.lower_bound(x);
        if (it != ss.end())
            ss.erase(it);
        ss.insert(x);
    }
    return ss.size() >= k;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        s[i] = s[i - 1] + x;
    }

    db l = 0, r = 1000;
    for (int cnt = 1; cnt <= 100; cnt++) {
        db mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    cout << fixed << setprecision(12) << l << "\n";
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3992kb

input:

7 3
1 3 1 2 2 2 1

output:

1.666666666667

result:

ok found '1.66667', expected '1.66667', error '0.00000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3832kb

input:

1 1
1

output:

1000.000000000000

result:

wrong answer 1st numbers differ - expected: '1.00000', found: '1000.00000', error = '999.00000'