結果
問題 |
No.1115 二つの数列 / Two Sequences
|
ユーザー |
|
提出日時 | 2020-07-17 22:04:43 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,210 bytes |
コンパイル時間 | 2,148 ms |
コンパイル使用メモリ | 104,704 KB |
実行使用メモリ | 58,496 KB |
最終ジャッジ日時 | 2024-11-30 00:04:56 |
合計ジャッジ時間 | 58,423 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 TLE * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var n = int.Parse(ReadLine()); //var s = Conasole.ReadLine().Split(' ') var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var ans = 0; for (int i = 0; i < n; i++) { int b_value = b[i]; int a_num = Array.IndexOf(a, b_value); ans += a_num - i; a = Swap(a, i, a_num); } WriteLine(ans); Out.Flush(); } public static int[] Swap(int[] a, int n, int m) { if (n == m) return a; else { int i = a[m]; for (int j = m; j > n; j--) { a[j] = a[j - 1]; } a[n] = i; } return a; } } }