結果

問題 No.143 豆
ユーザー fumi6328
提出日時 2018-07-08 00:20:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 289 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 22,528 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 11:01:43
合計ジャッジ時間 922 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d%d%d",&K,&N,&F);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%d",&A[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main()
{
	int K,N,F;
	int A[100],Msum,Ksum=0;	//sum,Ƒsum
	int i;
	
	scanf("%d%d%d",&K,&N,&F);
	for(i=0;i<F;i++){
		scanf("%d",&A[i]);
		Ksum+=A[i];
	}
	Msum=K*N;
	
	if(Msum>=Ksum)
		printf("%d",Msum-Ksum);
	else
		printf("-1");
	
	return 0;
}
0