結果

問題 No.204 ゴールデン・ウィーク(2)
コンテスト
ユーザー FF256grhy
提出日時 2015-05-08 23:45:50
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 629 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 237 ms
コンパイル使用メモリ 39,552 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-30 07:48:30
合計ジャッジ時間 1,672 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int note[16];

int main(void) {
	int d;
	char c[15];
	scanf("%d%s%s", &d, c, &c[7]);
	c[14] = 'x';
	
	int kinou = 'x', cnt = 0;
	note[0] = 15;
	int i;
	for(i = 0; i < 15; i++) {
		if(kinou != c[i]) {
			cnt++;
		}
		note[cnt]++;
		kinou = c[i];
	}
	note[cnt] += 15;
	
	int max = d;
	for(i = 1; i <= cnt - 1; i += 2) { // ここミスってた...
		int len;
		len = note[i] + ( (note[i - 1] <= d) ? (note[i - 1] + note[i - 2]) : d );
		if(max < len) { max = len; }
		len = note[i] + ( (note[i + 1] <= d) ? (note[i + 1] + note[i + 2]) : d );
		if(max < len) { max = len; }
	}
	printf("%d\n", max);
	return 0;
}
0