結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー | 6soukiti29 |
提出日時 | 2018-06-08 23:55:46 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 1,219 ms / 3,000 ms |
コード長 | 915 bytes |
コンパイル時間 | 4,711 ms |
コンパイル使用メモリ | 68,680 KB |
実行使用メモリ | 26,024 KB |
最終ジャッジ日時 | 2023-09-13 00:32:32 |
合計ジャッジ時間 | 13,206 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 3 ms
4,380 KB |
testcase_04 | AC | 3 ms
4,376 KB |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,388 KB |
testcase_07 | AC | 1,008 ms
22,204 KB |
testcase_08 | AC | 1,195 ms
25,940 KB |
testcase_09 | AC | 1,211 ms
25,960 KB |
testcase_10 | AC | 893 ms
22,444 KB |
testcase_11 | AC | 1,219 ms
26,024 KB |
testcase_12 | AC | 1,208 ms
26,004 KB |
testcase_13 | AC | 2 ms
4,384 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(3, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import sequtils,strutils,algorithm import sequtils,strutils type binaryIndexTree[I:static[int]] = array[I + 1,int] proc add(BIT :var binaryIndexTree,i : int, a : int)= var index = i while BIT[0] >= index: BIT[index] += a index += ((index xor (index - 1)) and index) proc sum(BIT : binaryIndexTree, i : int):int = var index = i while index > 0: result += BIT[index] index = (index and (index - 1)) var BIT : binaryIndexTree[500010] N = stdin.readline.parseInt A = newSeq[int](0) B : seq[int] a,s : int ans : int for n in 0..<N: a = stdin.readline.parseInt A.add(a) B = A.sorted(system.cmp) for n in 0..<N: A[n] = B.lowerBound(A[n]) + 1 BIT[0] = 500010 for n in 0..<N: a = n - BIT.sum(A[n]) s += a BIT.add(A[n], 1) echo s for i in A[0..<A.high]: s -= BIT.sum(i - 1) s += N - BIT.sum(i) echo s