結果
問題 | No.143 豆 |
ユーザー |
|
提出日時 | 2017-06-30 09:43:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 1,404 ms |
コンパイル使用メモリ | 157,828 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 10:47:08 |
合計ジャッジ時間 | 2,319 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:24:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d %d",&K,&N); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:27:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d",&F); | ~~~~~^~~~~~~~~ main.cpp:30:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d",&tosi); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int K; //一袋当たりの豆の数 int N; //Kを拾った数 int F; //人数 int total1; //K*Nの合計 int total2; //年齢の合計 int i; //ループカウント int tosi = 0; //初期化 K = 0; N = 0; F = 0; total1 = 0; total2 = 0; tosi = 0; /*豆の数*/ scanf("%d %d",&K,&N); total1 = K * N; /*人数*/ scanf("%d",&F); for(i = 1;i<=F;i++) { scanf("%d",&tosi); total2 += tosi; } if(total1<total2) { printf("-1\n"); } else { printf("%d\n",total1-total2); } return 0; }