QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#443960 | #8524. Weather Forecast | ucup-team3734# | WA | 0ms | 3968kb | C++23 | 1.6kb | 2024-06-15 16:55:45 | 2024-06-15 16:55:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef double lf;
int check(vector<int> &a, lf x) {
int n = (int) a.size();
vector<lf> b(n + 1);
b[0] = 0;
for (int i = 0; i < n; i++) {
b[i + 1] = b[i] + a[i] - x;
}
vector<lf> c;
for (int i = 0; i <= n; i++) {
if (b[i] > 0 && b[i] < b.back())
c.push_back(b[i]);
}
b = c;
n = (int) b.size();
if (b.empty()) return 0;
static constexpr lf INF = 1e18;
vector<lf> d(n + 1, INF);
d[0] = -INF;
for (int i = 0; i < n; i++) {
int l = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
if (d[l - 1] < a[i] && a[i] < d[l]) {
d[l] = a[i];
}
}
int ans = 0;
for (int l = 0; l <= n; l++) {
if (d[l] < INF)
ans = l;
}
return ans + 1;
}
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int &x : a) {
cin >> x;
}
lf left = *min_element(a.begin(), a.end()), right = *max_element(a.begin(), a.end());
while (right - left > 1e-5) {
lf mid = (left + right) / 2;
if (check(a, mid) >= k) {
left = mid;
} else {
right = mid;
}
}
cout << fixed << setprecision(10) << left << '\n';
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
int t = 1;
// cin >> t;
for (int i = 0; i < t; i++) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
7 3 1 3 1 2 2 2 1
output:
1.6666641235
result:
ok found '1.66666', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
1 1 1
output:
1.0000000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3968kb
input:
2 1 2 1
output:
1.0000000000
result:
wrong answer 1st numbers differ - expected: '1.50000', found: '1.00000', error = '0.50000'