結果

問題 No.576 E869120 and Rings
ユーザー TangentDayTangentDay
提出日時 2017-10-14 02:41:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,686 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 96,828 KB
実行使用メモリ 44,708 KB
最終ジャッジ日時 2024-04-28 18:03:59
合計ジャッジ時間 21,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 994 ms
41,688 KB
testcase_01 AC 989 ms
40,948 KB
testcase_02 AC 973 ms
40,236 KB
testcase_03 AC 977 ms
40,556 KB
testcase_04 AC 987 ms
40,984 KB
testcase_05 AC 1,034 ms
40,912 KB
testcase_06 AC 984 ms
41,280 KB
testcase_07 AC 983 ms
42,024 KB
testcase_08 WA -
testcase_09 AC 704 ms
40,644 KB
testcase_10 WA -
testcase_11 AC 735 ms
41,036 KB
testcase_12 AC 732 ms
41,916 KB
testcase_13 AC 732 ms
42,092 KB
testcase_14 AC 700 ms
42,260 KB
testcase_15 AC 671 ms
43,384 KB
testcase_16 AC 614 ms
44,708 KB
testcase_17 AC 710 ms
41,500 KB
testcase_18 AC 724 ms
41,928 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 752 ms
40,208 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 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);
    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(_,30){
        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