結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2017-08-12 04:08:28 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,173 bytes |
コンパイル時間 | 653 ms |
コンパイル使用メモリ | 106,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 21:30:38 |
合計ジャッジ時間 | 2,034 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 WA * 3 |
ソースコード
import std.algorithm; import std.array; import std.conv; import std.math; import std.stdio; import std.string; import std.range; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } int calc(int d, string s) { // 平日=0, 休日=1 int[] ss = s.map!(e => e == 'x' ? 0 : 1).array; auto as = 0.repeat().take(d).array; auto xs = as ~ ss ~ as; // 2 週間の前後を挟む int ans = 0; for (int i = 0; i < xs.length - d; i++) { // i 日目から連続で d 日休暇 auto ys = xs.dup; for (int j = i; j < i + d; j++) { // i 日目から d 日休暇 if (ys[j] == 1) // 休日はまたがない break; ys[j] = 1; } int holidays = 0; for (int j = 0; j < xs.length; j++) { if (ys[j] == 1) { holidays++; ans = max(ans, holidays); } else { holidays = 0; } } } return ans; } void main() { int d = readint(); auto s = readln.chomp; auto t = readln.chomp; writeln(calc(d, s ~ t)); }