結果

問題 No.143 豆
コンテスト
ユーザー rhincodon66
提出日時 2018-09-08 16:35:16
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 351 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 913 ms
コンパイル使用メモリ 179,260 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-03 14:00:11
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:15:20: warning: 'sum' may be used uninitialized [-Wmaybe-uninitialized]
   15 |                 sum+=a;
      |                 ~~~^~~
main.cpp:11:13: note: 'sum' was declared here
   11 |         int sum;
      |             ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k,n,f;cin >> k >> n >> f;
	int sum;
	for(int i=0;i<f;++i){
		int a;
		cin >> a;
		sum+=a;
	}
	if(k*n-sum>=0) cout << k*n-sum << endl;
	else cout << -1 << endl;
}
0