結果

問題 No.1687 What the Heck?
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-10-13 09:07:23
言語 Perl
(5.38.2)
結果
AC  
実行時間 754 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 6,120 KB
実行使用メモリ 43,364 KB
最終ジャッジ日時 2023-10-17 19:02:34
合計ジャッジ時間 6,810 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,292 KB
testcase_01 AC 8 ms
6,292 KB
testcase_02 AC 8 ms
6,292 KB
testcase_03 AC 8 ms
6,292 KB
testcase_04 AC 9 ms
6,292 KB
testcase_05 AC 8 ms
6,292 KB
testcase_06 AC 8 ms
6,284 KB
testcase_07 AC 227 ms
19,220 KB
testcase_08 AC 321 ms
24,936 KB
testcase_09 AC 220 ms
19,160 KB
testcase_10 AC 138 ms
14,584 KB
testcase_11 AC 153 ms
15,340 KB
testcase_12 AC 754 ms
43,364 KB
testcase_13 AC 749 ms
43,360 KB
testcase_14 AC 750 ms
43,360 KB
testcase_15 AC 743 ms
43,360 KB
testcase_16 AC 726 ms
42,868 KB
testcase_17 AC 42 ms
8,980 KB
testcase_18 AC 734 ms
43,364 KB
testcase_19 AC 11 ms
6,572 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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($ans, $now-$y);
}
print "$ans\n";
0