[BZOJ4989] [Usaco2017 Feb]Why Did the Cow Cross the Road(树状数组)
传送门
发现就是逆序对
可以树状数组求出
对于旋转操作,把一个序列最后面一个数移到开头,假设另一个序列的这个数在位置x,那么对答案的贡献 (n x) + (x 1)
#include <cstdio>#include <cstring>#include <iostream>#define N 200011#define LL long longusing namespace std;int n;int a[N], b[N], pos1[N], pos2[N];LL c[N], ans = 1ll * N * N;inline int read()inline void add(int x)inline LL query(int x)inline void solve()ans = min(ans, sum);for(i = n; i > 1; i)}int main()
上一篇:[BZOJ4993||4990] [Usaco2017 Feb]Why Did the Cow Cross the Road II(DP + 线段树)
下一篇:[BZOJ4994] [Usaco2017 Feb]Why Did the Cow Cross the Road III(树状数组)
树状数组
spc文件怎么看,spc文件用什么打开?
0文件怎么看,0文件用什么打开?
sparseimage文件怎么看,sparseimage文件用什么打开?
sp文件怎么看,sp文件用什么打开?
dv文件怎么看,dv文件用什么打开?
soundpack文件怎么看,soundpack文件用什么打开?
dus文件怎么看,dus文件用什么打开?
dtw文件怎么看,dtw文件用什么打开?
spdf文件怎么看,spdf文件用什么打开?
0文件怎么看,0文件用什么打开?