| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 642528 | Urvuk3 | Prosjek (COCI14_prosjek) | C++17 | 1 ms | 212 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e6,MAXA=1e6+5,INF=1e9;
const double EPS=1e-9;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define endl "\n"
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; }
ll n,m,k,q,x,y,z;
double res=0;
string s,t;
vector<double> a;
ifstream in;
#ifdef ONLINE_JUDGE
    #define in cin
#endif
bool check(double x){
    vector<double> pref(n+1,0);
    for(int i=1;i<=n;i++){
        pref[i]=pref[i-1]+(a[i]-x);
    }
    double minpref=0;
    for(int r=k;r<=n;r++){
        if(pref[r]-minpref>=0) return true;
        minpref=min(minpref,pref[r-k+1]);
    }
    return false;
}
void solve(){
    cin>>n>>k;
    a.resize(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    double l=1,r=MAXA;
    while(r-l>=EPS){
        if(check(mid)){
            res=mid;
            l=mid;
        }
        else r=mid;
    }
    cout<<fixed<<setprecision(6)<<res<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        in.open("D:\\UROS\\Programiranje\\input.in",ios::in);
    #endif
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
