結果

問題 No.397 NO MORE KADOMATSU
ユーザー moti
提出日時 2018-05-26 02:31:16
言語 Perl
(5.40.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 25,220 KB
平均クエリ数 651.67
最終ジャッジ日時 2024-07-17 01:44:28
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use strict;
use warnings;

my $n = <>; chomp $n;
my $l = <>; chomp $l;
my @arr = split/ /,$l;

my @res;
for (my $i = 0; $i < @arr; $i++) {
  for (my $j = 0; $j < $i; $j++) {
    if ($arr[$i] < $arr[$j]) {
      ($arr[$i], $arr[$j]) = ($arr[$j], $arr[$i]);
      push @res, [$i, $j];
    }
  }
}

print scalar(@res) . "\n";
print(join(' ', ($_->[0], $_->[1])) . "\n") for @res;

#die 'no more kadomatsu' unless -1 == <>;
0