結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2016-04-29 10:54:39 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 4,151 ms / 5,000 ms |
コード長 | 409 bytes |
コンパイル時間 | 1,082 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 01:43:49 |
合計ジャッジ時間 | 60,426 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d %d",&N,&K); | ^~~~~~~~~~~~~~~~~~~~ main.c:9:3: 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(){ int N,K; char s[50]; int i=0,k=0,sum=0; int ans=0; scanf("%d %d",&N,&K); scanf("%s",s); if(N==1 && s[0]!='0')ans=1; else{ while(k<K){ i=0; while(i<N){ if(sum==0)ans++; else sum--; if(s[i]=='0'); else if(s[i]=='1')sum++; else sum=sum+2; k++; if(k>=K)break; i++; } } } printf("%d\n",ans); return 0; }