結果

問題 No.1687 What the Heck?
ユーザー neko_the_shadow
提出日時 2021-10-13 09:07:23
言語 Perl
(5.40.0)
結果
AC  
実行時間 567 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 43,500 KB
最終ジャッジ日時 2024-09-17 16:14:57
合計ジャッジ時間 4,994 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
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