結果

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