From a7928020adb23fd8aaacb8be232009cbddea6efa Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 3 Jan 2021 08:41:16 +0800 Subject: [PATCH] =?UTF-8?q?#10114.=20=E3=80=8C=E4=B8=80=E6=9C=AC=E9=80=9A?= =?UTF-8?q?=204.1=20=E4=BE=8B=202=E3=80=8D=E6=95=B0=E6=98=9F=E6=98=9F=20St?= =?UTF-8?q?ars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1025579 --- LibreOJ/10114/10114.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 LibreOJ/10114/10114.cpp diff --git a/LibreOJ/10114/10114.cpp b/LibreOJ/10114/10114.cpp new file mode 100644 index 00000000..ef0c5286 --- /dev/null +++ b/LibreOJ/10114/10114.cpp @@ -0,0 +1,43 @@ +#include + +using namespace std; + +int n, x, y, val[33000], ans[16000]; + +struct node { + int x, y; +} t[16000]; + +int lowbit(int x) { + return x & (-x); +} + +void add(int p, int v) { + while (p <= 32001) { + val[p] += v; + p += lowbit(p); + } +} + +int sum(int p) { + int ans = 0; + while (p >= 1) { + ans += val[p]; + p -= lowbit(p); + } + return ans; +} + +int main() { + cin >> n; + for (int i = 0; i < n; i++) { + cin >> x >> y; + x++, y++; + ans[sum(x)]++; + add(x, 1); + } + for (int i = 0; i < n; i++) { + cout << ans[i] << endl; + } + return 0; +} \ No newline at end of file