結果

問題 No.397 NO MORE KADOMATSU
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-16 15:39:12
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 957 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 75,764 KB
実行使用メモリ 74,460 KB
平均クエリ数 57.78
最終ジャッジ日時 2023-09-23 11:45:45
合計ジャッジ時間 8,749 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
73,088 KB
testcase_01 AC 174 ms
72,580 KB
testcase_02 RE -
testcase_03 AC 190 ms
73,044 KB
testcase_04 AC 180 ms
73,016 KB
testcase_05 AC 193 ms
73,176 KB
testcase_06 AC 191 ms
72,868 KB
testcase_07 AC 190 ms
72,924 KB
testcase_08 RE -
testcase_09 AC 200 ms
70,960 KB
testcase_10 RE -
testcase_11 AC 198 ms
73,080 KB
testcase_12 AC 190 ms
72,636 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 172 ms
72,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        int c=0;
        int [][] exchange = new int [2][N];
        for(int i=0; i<N; i++){
            int max=0;
            for(int j=i+1; j<N; j++){
                max=Math.max(max,A[j]);
            }
            for(int j=i+1; j<N; j++){
                if(max==A[j]){
                    A[j]=A[i];
                    A[i]=max;
                    exchange[0][c]=i;
                    exchange[1][c]=j;
                    c++;
                    break;
                }
            }
        }
        System.out.println(c);
        for(int i=0; i<c; i++){
            System.out.println(exchange[0][i]+" "+exchange[1][i]);
        }
        int Dummy = sc.nextInt();
    }
}
0