結果

問題 No.576 E869120 and Rings
ユーザー chocoruskchocorusk
提出日時 2019-07-08 00:23:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 630 ms / 1,500 ms
コード長 1,264 bytes
コンパイル時間 1,001 ms
コンパイル使用メモリ 102,088 KB
実行使用メモリ 13,348 KB
最終ジャッジ日時 2024-04-15 19:11:26
合計ジャッジ時間 10,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 630 ms
12,960 KB
testcase_01 AC 538 ms
12,960 KB
testcase_02 AC 589 ms
12,832 KB
testcase_03 AC 598 ms
12,836 KB
testcase_04 AC 596 ms
12,832 KB
testcase_05 AC 540 ms
12,832 KB
testcase_06 AC 535 ms
12,960 KB
testcase_07 AC 593 ms
12,964 KB
testcase_08 AC 247 ms
12,704 KB
testcase_09 AC 217 ms
12,708 KB
testcase_10 AC 243 ms
12,704 KB
testcase_11 AC 224 ms
12,708 KB
testcase_12 AC 217 ms
12,832 KB
testcase_13 AC 183 ms
12,704 KB
testcase_14 AC 177 ms
13,220 KB
testcase_15 AC 148 ms
12,592 KB
testcase_16 AC 185 ms
12,592 KB
testcase_17 AC 175 ms
13,348 KB
testcase_18 AC 219 ms
12,832 KB
testcase_19 AC 218 ms
12,832 KB
testcase_20 AC 209 ms
12,648 KB
testcase_21 AC 220 ms
12,708 KB
testcase_22 AC 7 ms
11,392 KB
testcase_23 AC 8 ms
11,520 KB
testcase_24 AC 7 ms
11,392 KB
testcase_25 AC 7 ms
11,520 KB
testcase_26 AC 7 ms
11,520 KB
testcase_27 AC 8 ms
11,392 KB
testcase_28 AC 7 ms
11,392 KB
testcase_29 AC 7 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, k;
    cin>>n>>k;
    string a;
    cin>>a;
    a+=a;
    double x1=0, x2=1;
    for(int t=0; t<30; t++){
        double x=(x1+x2)/2;
        double s[1000010];
        s[0]=0;
        deque<int> deq;
        for(int i=0; i<2*n; i++){
            if(a[i]=='1') s[i+1]=s[i]+1-x;
            else s[i+1]=s[i]-x;
        }
        bool ok=0;
        for(int i=k; i<=2*n; i++){
            while(!deq.empty()){
                if(s[deq.back()]<=s[i]) deq.pop_back();
                else break;
            }
            deq.push_back(i);
            if(i>=n && s[deq.front()]>=s[i-n]){
                ok=1;
                break;
            }
            if(deq.front()==i-n+k) deq.pop_front();
        }
        if(ok) x1=x;
        else x2=x;
    }
    printf("%.7lf\n", x1);
    return 0;
}
0