結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-26 14:40:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2,694 ms / 5,000 ms |
| コード長 | 443 bytes |
| コンパイル時間 | 116 ms |
| コンパイル使用メモリ | 23,040 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 00:24:37 |
| 合計ジャッジ時間 | 39,042 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d %d %s",&n,&k,s);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(){
char s[52];
int n,k;
int i;
char *ps,*se;
int cost,prize;
scanf("%d %d %s",&n,&k,s);
for(i=0;i<n;i++)s[i]-='0';
cost=prize=0;
ps=s;
se=&s[n];
for(i=k;i;i--){
if(prize){
prize--;
}else{
cost++;
}
prize+=*ps;
if(++ps==se)ps=s;
}
printf("%d\n",cost);
return 0;
}