QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#446265 | #8524. Weather Forecast | rustiebeats | WA | 1ms | 5844kb | C++17 | 1.9kb | 2024-06-17 05:00:31 | 2024-06-17 05:00:31 |
Judging History
answer
#define _DE312BUG
// #include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
// using namespace atcoder;
#define endl "\n"
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<pii> vii;
const long double pi = acos(-1.0);
const int INF = 1987654331;
const ll LLINF = 1e18;
const double eps = 1e-9;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
////////////////////////
// #ifndef ONLINE_JUDGE
// #include "template.cpp"
// #else
// #define debug(...)
// #define debugArr(...)
// #endif
////////////////////////
// ll dist[52][52][2502];
ld arr[202020];
ld psum[202020];
int main(){
#ifdef _DEBUG
freopen ("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(NULL);
int N,K;cin>>N>>K;
for(int i=1;i<=N;i++)cin>>arr[i];
ld lo=0.0;
ld hi=1000.0;
int it=0;
while(it++<=100){
ld mid=(lo+hi)/2;
vector<ld> p;
ld s=0;
for(int i=1;i<=N;i++){
// if(i==1)p.push_back(arr[1]-mid);
// else p.push_back(p.back()+(arr[i]-mid));
s+=arr[i];
p.push_back(s-i*mid);
}
vector<ld> lis;
for(auto v:p){
if(v<0)continue;
if(lis.empty()||lis.back()<=v)lis.push_back(v);
else *lower_bound(lis.begin(),lis.end(),v)=v;
}
// cout<<mid<<" "<<lis.size()<<endl;
if(lis.size()>=K+1)lo=mid;
else hi=mid;
}
cout<<fixed;
cout<<setprecision(12);
cout<<lo<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5844kb
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: 3880kb
input:
1 1 1
output:
0.000000000000
result:
wrong answer 1st numbers differ - expected: '1.00000', found: '0.00000', error = '1.00000'