結果

問題 No.143 豆
ユーザー kapo
提出日時 2016-04-14 14:54:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 252 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 22,528 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 10:28:27
合計ジャッジ時間 710 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d %d %d", &k, &n, &f);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d", &j);
      |                 ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void)
{
	int i, k, n, f, sum=0, j;
	scanf("%d %d %d", &k, &n, &f);

	for (i = 0; i < f; i++) {
		scanf("%d", &j);
		sum += j;
	}

	if (sum > k*n) {
		printf("-1\n");
		return 0;
	}

	printf("%d\n", k*n-sum);
	
	return 0;
}
0