結果
| 問題 |
No.397 NO MORE KADOMATSU
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-02 19:10:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 2,000 ms |
| コード長 | 999 bytes |
| コンパイル時間 | 2,271 ms |
| コンパイル使用メモリ | 114,616 KB |
| 実行使用メモリ | 44,404 KB |
| 平均クエリ数 | 936.56 |
| 最終ジャッジ日時 | 2024-07-17 00:17:13 |
| 合計ジャッジ時間 | 4,907 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Cla {
static int N;
static int[] A;
static int Cnt = 0;
static List<int[]> Change = new List<int[]>();
static void Main() {
N = int.Parse(Console.ReadLine());
A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
for(int i = N - 1; i >= 1; i--) {
for(int j = 0; j < i; j++) {
if (A[j] > A[j + 1]) {
Cnt++;
int[] a = new int[2];
a[0] = j;
a[1] = j + 1;
Change.Add(a);
int w = A[j];
A[j] = A[j + 1];
A[j + 1] = w;
}
}
}
Console.WriteLine(Cnt);
for(int i = 0; i < Change.Count; i++) {
Console.WriteLine(Change[i][0] + " " + Change[i][1]);
}
Console.Out.Flush();
Console.ReadLine();
}
}