結果

問題 No.29 パワーアップ
ユーザー ynyn
提出日時 2014-11-25 18:46:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 574 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 26,816 KB
実行使用メモリ 11,360 KB
最終ジャッジ日時 2023-08-31 01:11:54
合計ジャッジ時間 12,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:8: warning: iteration 11 invokes undefined behavior [-Waggressive-loop-optimizations]
   up[i]=0;
   ~~~~~^~
main.cpp:16:11: note: within this loop
  for(i=0;i<=11;i++){
          ~^~~~
main.cpp:42:15: warning: iteration 10 invokes undefined behavior [-Waggressive-loop-optimizations]
   pup=pup+up[i]/2;
           ~~~~^
main.cpp:41:11: note: within this loop
  for(i=1;i<=11;i++){
          ~^~~~
main.cpp:43:5: warning: ‘sp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   sp=sp+up[i]%2;
   ~~^~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(){
	int N=0,M=0;
	int i=0,j=0;
	int pup=0;
	int a[301];
	int l[11];
	int up[11];
	int sp;

	scanf("%d",&N);

	M=N*3;

	for(i=0;i<=11;i++){
		a[i]=0;
		up[i]=0;
	}

	for(i=0;i<M;i++){
		scanf("%d",&a[i]);
	}

	for(i=1;i<=10;i++){
		for(j=0;j<M;j++){
			if(a[j]==i){
				l[i]=l[i]+1;
			}
		}
	}

	for(i=0;i<=11;i++){
		for(i=1;j<M;i++){
			if(a[j]==i){
				up[i]=up[i]+1;
			}
		}
	}

	for(i=1;i<=11;i++){
		pup=pup+up[i]/2;
		sp=sp+up[i]%2;
	}

	pup=pup+sp/4;
	printf("%d¥n",pup);

	return 0;

}
0