結果
| 問題 |
No.576 E869120 and Rings
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-20 22:29:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,214 bytes |
| コンパイル時間 | 1,889 ms |
| コンパイル使用メモリ | 169,544 KB |
| 実行使用メモリ | 14,348 KB |
| 最終ジャッジ日時 | 2025-04-20 22:29:40 |
| 合計ジャッジ時間 | 38,065 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 TLE * 8 |
ソースコード
#include <bits/stdc++.h>
#define int long long
//#define USE_FREOPEN
//#define MUL_TEST
#define FILENAME "sapphire"
using namespace std;
constexpr double eps = 1e-6;
int n,k;
string s;
void solve() {
cin >> n >> k >> s;
s = s + s;
auto chk = [&](double x) -> bool {
vector<double> sa(2 * n + 1,0.0);
for (int i = 0; i < 2 * n; i++) {
sa[i + 1] = sa[i] + (s[i] == '1' ? 1.0 : 0.0) - x;
}
deque<int> q;
for (int i = 1; i <= 2 * n; i++) {
if (i >= k) {
while (q.size() && sa[q.back()] >= sa[i - k]) q.pop_back();
q.push_back(i - k);
}
while (q.size() && q.front() < max(i - n,0ll)) q.pop_front();
if (i >= k) {
if (q.size()) {
if (sa[i] - sa[q.front()] >= -1e-9) return 1;
}
}
}
return 0;
};
double l = 0.0,r = 1.0;
for (int i = 1; i <= 100; i++) {
double mid = (l + r) / 2.0;
if (chk(mid)) l = mid;
else r = mid;
}
cout << setprecision(15) << r << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
#ifdef USE_FREOPEN
freopen(FILENAME ".in","r",stdin);
freopen(FILENAME ".out","w",stdout);
#endif
int _ = 1;
#ifdef MUL_TEST
cin >> _;
#endif
while (_--)
solve();
_^=_;
return 0^_^0;
}
vjudge1