結果
問題 |
No.576 E869120 and Rings
|
ユーザー |
|
提出日時 | 2017-10-13 22:55:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 833 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 62,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-17 11:39:45 |
合計ジャッジ時間 | 8,893 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 13 TLE * 3 |
ソースコード
#include <iostream> #include <iomanip> using namespace std; int main(){ int N, K; string jewelry; cin >> N >> K >> jewelry; int blue_gem = 0; for(int i = 0; i < K; i++){ blue_gem += jewelry[i] - '0'; } double ans = 0; for(int i = 0; i < N; i++){ blue_gem -= jewelry[(i - 1 + N) % N] - '0'; blue_gem += jewelry[(i + K - 1 + N) % N] - '0'; int blue_gem_plus = 0; for(int j = 1; j + K - 1 < N; j++){ if(jewelry[(i - j + N) % N] == '0'){ break; } blue_gem_plus++; } int plus_i = 0; for(int j = 1; j + K - 1 < N; j++){ if(jewelry[(i + K + j - 1 + N) % N] == '0'){ break; } blue_gem_plus++; plus_i++; } i += plus_i; double ans_tmp = (blue_gem_plus + blue_gem) / double(blue_gem_plus + K); if(ans < ans_tmp){ ans = ans_tmp; } } cout << setprecision(10) << ans << endl; }