QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#442722 | #8524. Weather Forecast | ucup-team133# | WA | 0ms | 4044kb | C++17 | 3.6kb | 2024-06-15 13:21:52 | 2024-06-15 13:21:52 |
Judging History
answer
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <chrono>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i=0;i<n;i+=1)
#define rrep(i,n) for (int i=n-1;i>-1;i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << " )\n";
template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<class T>
bool chmin(T &a, T b){
if (a>b){
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b){
if (a<b){
a = b;
return true;
}
return false;
}
template<class T>
T sum(vec<T> x){
T res=0;
for (auto e:x){
res += e;
}
return res;
}
template<class T>
void printv(vec<T> x){
for (auto e:x){
cout<<e<<" ";
}
cout<<endl;
}
template<class T,class U>
ostream& operator<<(ostream& os, const pair<T,U>& A){
os << "(" << A.first <<", " << A.second << ")";
return os;
}
template<class T>
ostream& operator<<(ostream& os, const set<T>& S){
os << "set{";
for (auto a:S){
os << a;
auto it = S.find(a);
it++;
if (it!=S.end()){
os << ", ";
}
}
os << "}";
return os;
}
template<class T>
ostream& operator<<(ostream& os, const tuple<T,T,T>& a){
auto [x,y,z] = a;
os << "(" << x << ", " << y << ", " << z << ")";
return os;
}
template<class T>
ostream& operator<<(ostream& os, const map<ll,T>& A){
os << "map{";
for (auto e:A){
os << e.first;
os << ":";
os << e.second;
os << ", ";
}
os << "}";
return os;
}
template<class T>
ostream& operator<<(ostream& os, const vec<T>& A){
os << "[";
rep(i,A.size()){
os << A[i];
if (i!=A.size()-1){
os << ", ";
}
}
os << "]" ;
return os;
}
template <class T> void mkuni(vector<T>& v) {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T> int lwb(const vector<T>& v, const T& x) {
return distance(v.begin(), lower_bound(v.begin(), v.end(), x));
}
void solve(){
int N,K;
cin>>N>>K;
vec<int> A(N);
rep(i,N) cin>>A[i];
auto cond = [&](double x){
vec<double> cum(N+1,0);
rep(i,N){
cum[i+1] = cum[i] + A[i] - x;
}
vec<double> dp = {0};
for (int i=1;i<N;i++){
if (dp.back() <= cum[i]){
dp.push_back(cum[i]);
continue;
}
int idx = lwb(dp,cum[i]);
dp[idx] = cum[i];
}
if (dp.back() <= cum[N]){
return int(dp.size());
}
else{
return lwb(dp,cum[N]);
}
};
double ok = 0,ng = 1001;
rep(_,50){
double mid = (ok+ng)/2;
if (cond(mid) >= K){
ok = mid;
}
else{
ng = mid;
}
}
cout << ok << "\n";
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
int T = 1;
while (T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4044kb
input:
7 3 1 3 1 2 2 2 1
output:
1.666666666666499
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
1 1 1
output:
0.999999999999188
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4044kb
input:
2 1 2 1
output:
1.499999999999671
result:
ok found '1.50000', expected '1.50000', error '0.00000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
3 2 2 4 4
output:
3.999999999999420
result:
wrong answer 1st numbers differ - expected: '3.00000', found: '4.00000', error = '1.00000'