結果

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

テストケース

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


	
	for(i=0; i<block; ++i){
		for(j=0; j<x; ++j){
			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[j];
		}
	}
	for(i=0; i<rem; ++i){
		if(p == 0) ++ans;
		else --p;
		p += v[i];
	}

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