#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn=10000000+3;
const int mod=1000000007;
struct node
{
LL L,T,W,H;
};
int n;
LL x[maxn];
LL sum[maxn];
LL allsum=0;
struct node oase[maxn];
int main()
{
ios::sync_with_stdio(0);
//freopen("in.txt","r",stdin);
int k,r;
cin>>k;
while(k--)
{
// scanf("%d",&r);
// scanf("%d",&n);
cin>>r>>n;
mst(sum,0);
mst(x,0);
allsum=0;
for(int i=0; i<n; i++)
{
// scanf("%d%d%d%d",&oase[i].L,&oase[i].T,&oase[i].W,&oase[i].H);
cin>>oase[i].L>>oase[i].T>>oase[i].W>>oase[i].H;
//cout<<oase[i].L<<endl;
allsum+=oase[i].W*oase[i].H;
for(int j=oase[i].L; j<oase[i].W+oase[i].L; j++)
{
x[j]+=oase[i].H;
}
}
// printf("allsum=%d\n",allsum);
int i=0;
LL sum=0;
for(i=0; 2*sum<allsum; i++)
{
sum+=x[i];
//printf("sum[%d]=%d\n",i,sum[i]);
}
while(x[i]==0&&i<r)
i++;
cout<<i<<endl;
}
return 0;
}
Xiongnu's Land(扫描线)
猜你喜欢
转载自www.cnblogs.com/sylvite/p/9563764.html
今日推荐
周排行