結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2017-08-12 04:15:11 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,174 bytes |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 106,860 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 21:30:41 |
| 合計ジャッジ時間 | 1,855 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
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));
}
norioc