結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
![]() |
提出日時 | 2014-11-26 00:16:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3,012 ms / 5,000 ms |
コード長 | 303 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 23:58:21 |
合計ジャッジ時間 | 41,707 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d %d\n",&N,&K); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%s\n",S); | ~~~~~^~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ int N; int K; char S[100]; scanf("%d %d\n",&N,&K); scanf("%s\n",S); int cnt=0; int stk=0; int p=0; while(K>0){ if(p==N)p=0; if(stk>0){ stk--; }else{ cnt++; } K--; stk+=(int)(S[p]-'0'); p++; } printf("%d\n",cnt); }