题意: 解法: 时间复杂度: std: #include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = 500005; struct node{ int x; ll y; }a[maxn]; ll b[maxn]; int main() { int t,n,m,x; scanf("%d",&t); while(t--){ memset(b,0,sizeof(b)); scanf("%d%d",&n,&m); for(int i=1;i<=n;i...