传送门
开2个树状数组
一个存的是下标,一个存的是数量
细节。。。看标称吧,懒得说了,好气啊
#include <cstdio> #include <iostream> #include <algorithm> #define N 20001 #define LL long long #define max(x, y) ((x) > (y) ? (x) : (y)) int n, m; LL ans, sum, c[N], d[N]; struct node p[N]; inline int read() inline bool cmp(node x, node y) inline LL query1(int x) inline LL query2(int x) inline void add1(int x, LL y) inline void add2(int x, LL y) int main() std::sort(p + 1, p + n + 1, cmp); for(i = 1; i <= n; i++) printf("%lld\n", ans); return 0; }
上一篇:[BZOJ4993||4990] [Usaco2017 Feb]Why Did the Cow Cross the Road II(DP + 线段树)
下一篇:[BZOJ4994] [Usaco2017 Feb]Why Did the Cow Cross the Road III(树状数组)
树状数组









