結果

問題 No.143 豆
ユーザー CotaSirogami
提出日時 2019-02-25 16:49:42
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 553 bytes
コンパイル時間 2,803 ms
コンパイル使用メモリ 138,344 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 11:09:38
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main() {
	int k, n, f;
	cin >> k >> n >> f;
	int a[f];
	int sum = k * n;
	for (int i = 0; i < f; i++) {
		cin >> a[i];
	}


	int out = 0;
	for (int i = 0; i < f; i++) {
		if (out + a[i] > sum){
			cout << -1 << endl;
			return 0;
		}
		out += a[i];
	}
	cout << sum - out << endl;
}
0