結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2017-03-23 15:02:08 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 470 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 11:57:01 |
合計ジャッジ時間 | 1,017 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s",s); | ^~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include<string.h>int main(void) {int i,j,min=100,w=0,count=0;char s[100];scanf("%s",s);for(i=0;i<strlen(s);i++){w=0;count=0;if(s[i]=='c'){count++;for(j=i+1;j<strlen(s);j++){if(s[j]== 'w'){count++;w++;if(w==2){if(min>count){min=count;}// printf("%d\n",min);break;}}else count++;}}}printf("%d",(min!=100? min : -1));return 0;}