結果
問題 |
No.742 にゃんにゃんにゃん 猫の挨拶
|
ユーザー |
![]() |
提出日時 | 2018-10-08 15:36:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,500 ms |
コード長 | 820 bytes |
コンパイル時間 | 5,252 ms |
コンパイル使用メモリ | 106,776 KB |
実行使用メモリ | 27,712 KB |
最終ジャッジ日時 | 2024-10-12 15:01:26 |
合計ジャッジ時間 | 2,524 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var a = new int[n]; for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim()); var bit = new int[n + 1]; var ans = 0; for (int i = 0; i < n; i++) { ans += i - getSum(a[i], bit); addix(a[i], 1, bit, n); } Console.WriteLine(ans); } public static int getSum(int i, int[] bit) { var s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } public static void addix(int i, int x, int[] bit, int n) { while (i <= n) { bit[i] += x; i += i & -i; } } }