結果

問題 No.576 E869120 and Rings
ユーザー TangentDayTangentDay
提出日時 2017-10-14 02:45:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,691 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 96,988 KB
実行使用メモリ 46,284 KB
最終ジャッジ日時 2024-04-28 18:07:10
合計ジャッジ時間 27,570 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,349 ms
42,132 KB
testcase_01 AC 1,303 ms
41,960 KB
testcase_02 AC 1,317 ms
41,544 KB
testcase_03 AC 1,316 ms
41,448 KB
testcase_04 AC 1,336 ms
42,280 KB
testcase_05 AC 1,339 ms
42,296 KB
testcase_06 AC 1,322 ms
41,072 KB
testcase_07 AC 1,322 ms
42,480 KB
testcase_08 WA -
testcase_09 AC 974 ms
41,872 KB
testcase_10 WA -
testcase_11 AC 990 ms
41,632 KB
testcase_12 AC 980 ms
41,960 KB
testcase_13 AC 1,015 ms
44,712 KB
testcase_14 AC 959 ms
43,188 KB
testcase_15 AC 912 ms
45,096 KB
testcase_16 AC 831 ms
46,284 KB
testcase_17 AC 975 ms
43,800 KB
testcase_18 AC 1,003 ms
41,796 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 966 ms
42,180 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

vector<double> slide_min(vector<double> &a, int k, vector<double> & ret){
    deque<double> dq;
    REP(i,a.size()){
        while (!dq.empty() && a[dq.back()] >= a[i]) dq.pop_back();
        dq.push_back(i);
        if (i - k + 1 >= 0){
            ret.push_back(a[dq.front()]);
            if (dq.front() == i - k + 1) dq.pop_front();
        }
    }
    return ret;
}

bool check(vector<double> &a, int k){
    int n = a.size() / 2;
    vector<double> b(2*n+1);
    REP(i,2*n) b[i+1] += b[i] + a[i];
    vector<double> mi;
    slide_min(b, n - k + 1, mi);
    REP(i,n) if (mi[i] <= b[n+1+i]) return true;
    return false;
}

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    // cout << 0 << endl;
    // return 0;

    vector<double> a(n);
    REP(i,n) a[i] = s[i] - '0';
    REP(i,n) a.push_back(a[i]);

    double ok = 0.0, ng = 1.0;
    REP(_,40){
        vector<double> b(a);
        double mi = (ok + ng) / 2.0;
        REP(i,2*n) b[i] -= mi;
        if (check(b, k)) ok = mi;
        else ng = mi;
    }
    printf("%.10f\n", ok);

    return 0;
}
0