結果

問題 No.143 豆
ユーザー yk Tsutaya
提出日時 2023-05-13 01:34:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 323 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 64,072 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-28 21:54:48
合計ジャッジ時間 1,211 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:12:12: warning: 'A' may be used uninitialized [-Wmaybe-uninitialized]
   12 |     result = K * N - A;
      |     ~~~~~~~^~~~~~~~~~~
main.cpp:6:21: note: 'A' was declared here
    6 |     int K, N, F, a, A, result;
      |                     ^

ソースコード

diff #

#include <iostream>

using namespace std;

int main() {
    int K, N, F, a, A, result;
    cin >> K >> N >> F;
    for(int i = 0; i < F; i++){
        cin >> a;
        A += a;    
    }
    result = K * N - A;
    if(result < 0){
        cout << -1 << endl;
    }else{
        cout << result << endl;
    }
    return 0;
}
0