QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#444893 | #8524. Weather Forecast | ucup-team3608# | WA | 0ms | 3820kb | C++23 | 1.0kb | 2024-06-15 22:04:27 | 2024-06-15 22:04:29 |
Judging History
answer
#include <bits/stdc++.h>
#define st first
#define nd second
using lint = long long;
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr lint linf = 0x3f3f3f3f3f3f3f3f;
using namespace std;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n, k;
cin>>n>>k;
vector<int>a(n);
for(int i=0;i<n;i++) cin>>a[i];
double lo = 0, hi = 1000;
for(int z=0;z<40;z++){
double mid = (lo + hi) / 2;
vector<double>b(n);
for(int i=0;i<n;i++) b[i] = a[i] - mid;
vector<double>dp(1);
dp[0] = 0;
double pref = 0;
for(int i=0;i<n;i++){
pref += b[i];
if(pref < 0) continue;
int it = int(lower_bound(dp.begin(), dp.end(), pref) - dp.begin());
if(it == dp.size()) dp.push_back(pref);
else dp[it+1] = min(dp[it+1], pref);
}
if(dp.size() > k) lo = mid;
else hi = mid;
}
cout<<fixed<<setprecision(6);
cout<<lo<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
7 3 1 3 1 2 2 2 1
output:
1.666667
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 1 1
output:
1.000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3812kb
input:
2 1 2 1
output:
2.000000
result:
wrong answer 1st numbers differ - expected: '1.50000', found: '2.00000', error = '0.50000'