From ac313d36a369176aeb0dd054e388d840de246e52 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 16 Nov 2024 17:01:53 +0800 Subject: [PATCH] update --- src/P1972/P1972.cpp | 81 ++ src/P1972/P1972_1.in | 3003 +++++++++++++++++++++++++++++++++++++++++ src/P1972/P1972_1.out | 3000 ++++++++++++++++++++++++++++++++++++++++ test.cpp | 0 4 files changed, 6084 insertions(+) create mode 100644 src/P1972/P1972.cpp create mode 100644 src/P1972/P1972_1.in create mode 100644 src/P1972/P1972_1.out delete mode 100755 test.cpp diff --git a/src/P1972/P1972.cpp b/src/P1972/P1972.cpp new file mode 100644 index 0000000..5290188 --- /dev/null +++ b/src/P1972/P1972.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include + +using ll = int64_t; +using std::cin, std::cout; + +const ll maxn = 1e6+5; +ll n, kds[maxn], m, anss[maxn], viss[maxn], bits[maxn]; + +struct Sch{ + ll l, r, pos; +}schs[maxn]; + +ll lb(const ll &v){ + return v&(-v); +} + +void tadd(ll idx, const ll &v){ + while(idx<=n){ + bits[idx]+=v; + idx+=lb(idx); + } +} + +ll tpsch(ll idx){ + ll res{}; + while(idx!=0){ + res+=bits[idx]; + idx-=lb(idx); + } + return res; +} + +#define DB(v){cout<<#v<<": "<<(v)<<'\n';}; + +int main(){ + std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); + + cin>>n; + for(ll i{1};i<=n;i++){ + cin>>kds[i]; + } + cin>>m; + for(ll i{1};i<=m;i++){ + cin>>schs[i].l>>schs[i].r; + schs[i].pos=i; + } + std::sort(schs+1, schs+1+m, [](const Sch &a, const Sch &b)->bool{ + return a.r