結果

問題 No.143 豆
ユーザー Kato ShinyaKato Shinya
提出日時 2017-04-01 18:45:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 918 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 27,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 16:59:10
合計ジャッジ時間 1,108 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

typedef struct {
  int b_nums;
  int s_nums;
  int total;
} beansInfo;

typedef struct {
  int fam_num;
  int age;
  int age_total;
} familyInfo;

void beans_sum(beansInfo *p);
void age_sum(familyInfo *p);
void print_result(beansInfo *dp, familyInfo *fp);

int main(void)
{
  beansInfo beans;
  familyInfo family;

  scanf("%d %d %d", &beans.b_nums, &beans.s_nums, &family.fam_num);

  beans_sum(&beans);
  age_sum(&family);
  print_result(&beans, &family);

  return 0;
}

void beans_sum(beansInfo *beans)
{
  beans->total = beans->b_nums * beans->s_nums;
}

void age_sum(familyInfo *family)
{
  family->age_total = 0;

  for (int i = 0; i < family->fam_num; ++i) {
    scanf("%d", &family->age);
    family->age_total += family->age;
  }
}

void print_result(beansInfo *beans, familyInfo *family)
{
  int result = beans->total - family->age_total;
  printf("%d\n", (result >= 0 ? result : -1));
}
0