题意:有n个竹子,m个查询,要求每次切割竹子到一定高度,且每次切割的总长度相同,y次切完,问你第x次切割之后的高度是多少
题解:每次切割掉的长度Σai/y,那么第x次切割完,切割掉的总长度应该为Σai*x/y,同时我们可以二分第x次切割完的高度,设二分的高度为h,则切割掉的总长度=高于h的竹子的高度总和-h*高于h的竹子的数量,这个与Σai*x/y相比就可以了
// #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 0x3f3f3f3f;
const int maxn = 2e5+5;
const double eps=1e-8;
struct node {
int l,r,sum;
ll val;
}T[maxn*20];
int rt[maxn],a[maxn];
ll pre[maxn];
int n,m,tot;
void build(i