結果

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

ソースコード

diff #

/*
 * 143.cpp
 *
 *  Created on: 2017/08/26
 *      Author: pinebooks
 */

#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int K, N, F;
  scanf("%d%d%d", &K, &N, &F);
  int sum = 0;
  for (int i = 0; i < F; ++i) {
    int a;
    scanf("%d", &a);
    sum += a;
  }
  if (K * N >= sum)
    printf("%d", K * N - sum);
  else
    printf("%d", -1);
  return 0;
}
0