結果

問題 No.576 E869120 and Rings
ユーザー ei1333333ei1333333
提出日時 2017-10-13 22:49:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 956 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 211,260 KB
実行使用メモリ 47,260 KB
最終ジャッジ日時 2024-04-28 17:37:54
合計ジャッジ時間 7,858 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long int64;

int main()
{
  int64 N, K;
  string A;

  cin >> N >> K;
  cin >> A;

  auto check = [&](double k)
  {
    int sum = 0;

    queue< double > lazy, lazy2;
    multiset< double > bit;
    bit.emplace(1e9);
    lazy.emplace(0.0);
    lazy2.emplace(0.0);
    for(int i = 0; i < N + N; i++) {
      if(K <= i + 1) {
        bit.emplace(lazy.front());
        lazy.pop();
      }
      if(K <= i + 1 - N) {
        bit.erase(bit.find(lazy2.front()));
        lazy2.pop();
      }
      sum += A[i % N] - '0';
      if(*bit.begin() <= sum - (i + 1) * k) return (true);
      lazy.emplace(sum - (i + 1) * k);
      lazy2.emplace(sum - (i + 1) * k);
    }
    return (false);
  };

  double low = 0.0, high = 1.0;
  for(int i = 0; i < 44; i++) {
    double mid = (low + high) * 0.5;
    if(check(mid)) low = mid;
    else high = mid;
  }
  cout << fixed << setprecision(10) << low << endl;

}
0