結果
問題 | No.143 豆 |
ユーザー |
![]() |
提出日時 | 2018-04-29 01:30:36 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 573 ms |
コンパイル使用メモリ | 59,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 10:58:14 |
合計ジャッジ時間 | 1,234 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d %d %d", &k, &n, &f); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d", &t); | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>#include <vector>using namespace std;int main() {int k,n,f;vector<int> a;scanf("%d %d %d", &k, &n, &f);int t;for(int i = 0; i < f; i++) {scanf("%d", &t);a.push_back(t);}int beans = k * n;for (int i = 0; i < a.size(); i++) {beans -= a[i];}if (beans < 0) {printf("-1\n");}else {printf("%d\n", beans);}return 0;}