Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
差分数组 求重叠线段最大数#include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> #include <math.h> using namespace std; const int MOD=(int)1e9+10; const int maxn=4e2+11; int a[maxn]; int main() { // freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin); // freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout); int n,m,x,y; scanf("%d",&n); while(n--){ scanf("%d",&m); memset(a,0,sizeof(a)); while(m--){ scanf("%d%d",&x,&y); if(x&1) x++;if(y&1) y++; if(x>y) swap(x,y); a[x]++;a[y+1]--; } for(int i=1;i<maxn;i++) a[i]+=a[i-1]; printf("%d\n",*max_element(a,a+maxn)*10); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator