結果

問題 No.1687 What the Heck?
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-10-13 09:06:26
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 6,132 KB
実行使用メモリ 43,316 KB
最終ジャッジ日時 2023-10-17 19:02:27
合計ジャッジ時間 8,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,272 KB
testcase_01 AC 8 ms
6,264 KB
testcase_02 AC 8 ms
6,272 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 226 ms
19,120 KB
testcase_10 AC 140 ms
14,560 KB
testcase_11 AC 152 ms
15,296 KB
testcase_12 AC 754 ms
43,316 KB
testcase_13 AC 771 ms
43,316 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use strict;
use warnings;
use List::Util qw(max);

my $n = <>;
my @a = split / /, <>;
my @b = sort {$a[$a-1] <=> $a[$b-1]} 1..$n;

my $ans = 0;
my $now = 0;
for (my $i = 0; $i < $n-1; $i++) {
    my $x = $b[$i];
    my $y = $b[$i+1];
    
    $now += $x;
    $ans = max($x, $now-$y);
}
print "$ans\n";
0