結果

問題 No.143 豆
ユーザー togaerror
提出日時 2015-03-17 22:27:16
言語 Perl
(5.40.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 304 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 10:16:56
合計ジャッジ時間 1,046 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use warnings;
use strict;

my ($k, $n, $f) = split / /, <>;
my $year = <>;
chomp $year;
my @array = split / /, $year;
my $total = 0;

for(my $i = 0; $i < $f; $i++) {
	$total += $array[$i]; 
}

my $ans = $k * $n - $total;

if($ans < 0) {
	print "-1\n";
} else {
	print "$ans\n";
}

exit;
0