結果

問題 No.78 クジ付きアイスバー
ユーザー koyumeishikoyumeishi
提出日時 2014-11-26 01:57:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 23,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 04:58:23
合計ジャッジ時間 6,753 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 72 ms
5,376 KB
testcase_08 AC 116 ms
5,376 KB
testcase_09 AC 367 ms
5,376 KB
testcase_10 AC 178 ms
5,376 KB
testcase_11 AC 89 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 353 ms
5,376 KB
testcase_14 AC 355 ms
5,376 KB
testcase_15 AC 140 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 279 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 0 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 437 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d %d\n%s", &n, &k, s);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

//愚直解で通るのかしら

#include "stdio.h"

int main(){
	int n;
	int k;
	int v[100];
	char s[100];
	
	int m;
	int block;
	int rem;
	int x;
	int y;
	
	int ans = 0;
	int p = 0;
	int i,j;
	int q = 0;
	
	scanf("%d %d\n%s", &n, &k, s);
	
	m = (100/n) * n;
	block = k/m;
	rem = k%m;
	x = m/4;
	y = m%4;
	
	for(i=0; i<m; i++){
		v[i] = (s[(i%n)] - '0');
	}


	q = 4*x;
	for(i=0; i<block; ++i){
		for(j=0; j<x; j+=4){
			if(p == 0) ++ans;
			else --p;
			p += v[j];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+1];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+2];
			
			if(p == 0) ++ans;
			else --p;
			p += v[j+3];
		}
		for(j=0; j<y; j++){
			if(p == 0) ++ans;
			else --p;
			p += v[q+j];
		}
	}
	for(i=0; i<rem; ++i){
		if(p == 0) ++ans;
		else --p;
		p += v[i];
	}

	printf("%d\n", ans);
	return 0;
}
0