QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#543040#8524. Weather Forecastucup-team4821#WA 1ms5972kbC++20927b2024-09-01 13:04:282024-09-01 13:04:28

Judging History

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

  • [2024-09-01 13:04:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5972kb
  • [2024-09-01 13:04:28]
  • 提交

answer

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

using i64 = long long;

const int P = 1e9 + 7;
void add(int &x, int y) { (x += y) >= P && (x -= P); }

const int N = 200005;
int n, a[N], k;
double s[N], f[N];

bool check(double mid) {
    int top = 0;
    f[++top] = 0;
    for (int i = 1; i <= n; ++i) {
        s[i] = s[i - 1] + a[i] - mid;
        int pos = lower_bound(f + 1, f + top + 1, s[i]) - f;
        if (i == n) return pos > k;
        f[pos] = s[i];
        if (pos == top + 1) ++top;
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];

    double l = 1, r = 1000;
    for (int t = 0; t < 30; ++t) {
        double mid = (l + r) / 2;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }

    cout << setprecision(20) << l << "\n";

    return 0;
}

详细

Test #1:

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

input:

7 3
1 3 1 2 2 2 1

output:

1.6666662693023681641

result:

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

Test #2:

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

input:

1 1
1

output:

1

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

2 1
2 1

output:

1.499999701976776123

result:

ok found '1.50000', expected '1.50000', error '0.00000'

Test #4:

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

input:

3 2
2 4 4

output:

3.9999991422519087791

result:

wrong answer 1st numbers differ - expected: '3.00000', found: '4.00000', error = '1.00000'