結果

問題 No.78 クジ付きアイスバー
ユーザー notetonousnotetonous
提出日時 2016-04-29 10:54:39
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 4,174 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 14:47:13
合計ジャッジ時間 59,672 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 0 ms
6,820 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 777 ms
6,940 KB
testcase_06 AC 1,993 ms
6,944 KB
testcase_07 AC 812 ms
6,940 KB
testcase_08 AC 1,234 ms
6,944 KB
testcase_09 AC 4,122 ms
6,944 KB
testcase_10 AC 2,135 ms
6,940 KB
testcase_11 AC 1,049 ms
6,940 KB
testcase_12 AC 3,469 ms
6,944 KB
testcase_13 AC 3,720 ms
6,944 KB
testcase_14 AC 4,010 ms
6,940 KB
testcase_15 AC 1,814 ms
6,940 KB
testcase_16 AC 2,625 ms
6,940 KB
testcase_17 AC 3,084 ms
6,940 KB
testcase_18 AC 3,111 ms
6,944 KB
testcase_19 AC 3,361 ms
6,944 KB
testcase_20 AC 3,500 ms
6,944 KB
testcase_21 AC 4,074 ms
6,944 KB
testcase_22 AC 3,746 ms
6,944 KB
testcase_23 AC 0 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 0 ms
6,948 KB
testcase_26 AC 0 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 0 ms
6,944 KB
testcase_30 AC 0 ms
6,940 KB
testcase_31 AC 0 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 4 ms
6,944 KB
testcase_34 AC 868 ms
6,944 KB
testcase_35 AC 1,169 ms
6,940 KB
testcase_36 AC 3,356 ms
6,940 KB
testcase_37 AC 4,174 ms
6,944 KB
testcase_38 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |   ^~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0