結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2015-05-08 23:45:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 629 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 22,912 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:40:14 |
合計ジャッジ時間 | 1,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d%s%s", &d, c, &c[7]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }