
Apple9 News Style Article Example
A Sample Post Imitating Apple News Layout
This is a lead paragraph or intro excerpt that appears prominently in the Apple News style layout.
Introduction
Welcome to this sample article. Here, we’ll explore various Markdown elements rendered in an Apple News-inspired design.
Chapter 5
Exercise 1
Given the pseudo code below:
1 | find(n,a,b): |
The time complexity is $T(n) = T(\lceil \frac n 2 \rceil) + 2 \Rightarrow T(n)=2\lceil\log n\rceil = O(\log n)$.
Exercise 2
We can use Binary Indexed Tree (also called Fenwick Tree) to count inversions.
You can refer to this page to learn it: 树状数组 - OI Wiki
1 | int lowbit(int x){return x&-x;} |
After discretization, each time we can add $a_i$ and query for how many $a_j > a_i$ with $j<i$.
1 | int main(){ |
For this problem, we can still use Fenwick Tree to count significant inversions.
After discretization, each time we can add $a_i$ and query for how many $a_j > 2a_i$ with $j<i$.
1 | int main(){ |
Time complexity is $O(n\log n)$.