結果
問題 | No.576 E869120 and Rings |
ユーザー | ryoissy |
提出日時 | 2017-10-14 17:30:04 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 817 bytes |
コンパイル時間 | 1,391 ms |
コンパイル使用メモリ | 164,348 KB |
実行使用メモリ | 16,388 KB |
最終ジャッジ日時 | 2024-04-28 19:36:00 |
合計ジャッジ時間 | 39,132 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | AC | 1,370 ms
12,384 KB |
testcase_09 | AC | 1,491 ms
12,476 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,428 ms
12,576 KB |
testcase_12 | AC | 1,401 ms
12,396 KB |
testcase_13 | AC | 1,207 ms
12,724 KB |
testcase_14 | AC | 1,302 ms
12,272 KB |
testcase_15 | AC | 1,030 ms
16,260 KB |
testcase_16 | AC | 1,065 ms
16,388 KB |
testcase_17 | AC | 1,270 ms
12,224 KB |
testcase_18 | AC | 1,368 ms
12,328 KB |
testcase_19 | AC | 1,356 ms
12,220 KB |
testcase_20 | AC | 836 ms
12,340 KB |
testcase_21 | AC | 1,377 ms
12,492 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%d%d",&n,&k); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define MOD 1000000007LL #define EPS 1e-10 using namespace std; typedef long long ll; typedef pair<double,int> P; int n,k; string str; double sum[1000001]; bool C(double vv){ for(int i=0;i<str.size();i++){ sum[i+1]=sum[i]-vv; if(str[i]=='1')sum[i+1]+=1.0; } deque<P> mx; for(int i=k;i<=str.size();i++){ while(mx.size()){ if(mx[0].second<=i-n){ mx.pop_front(); }else break; } while(mx.size()){ if(mx.back().first>sum[i-k])mx.pop_back(); else break; } mx.push_back(P(sum[i-k],i-k)); if(mx.size() && sum[i]-mx[0].first>0.0)return true; } return false; } int main(void){ scanf("%d%d",&n,&k); cin >> str; str+=str; double l=0.0,r=1.0; for(int i=0;i<100;i++){ double mid=(l+r)/2; if(C(mid))l=mid; else r=mid; } printf("%.10f\n",l); return 0; }