Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## wa吐血了，大神们帮忙看一下。。。。

Posted by shllhsno1 at 2012-11-08 16:30:02 on Problem 1230
```#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int t,n,k;
struct walls{
int s,t,num;
}wall[105];
int cnt[105];
bool cmp(walls a,walls b)
{
if(a.s == b.s)
return a.t<b.t;
return a.s<b.s;
}
int main()
{
int i,j,sun,ans,a,b;
bool flag;
scanf("%d",&t);
while(t--)
{
sun = 0;
memset(cnt,0,sizeof(cnt));
scanf("%d%d",&n,&k);
for(i = 1;i<=n;i++)
{
scanf("%d%d%d%d",&a,&wall[i].num,&b,&wall[i].num);
wall[i].s = a<b?a:b;
wall[i].t = a>b?a:b;
}
sort(wall+1,wall+n+1,cmp);
for(i = 1;i<=n;i++)
{

for(j = wall[i].s;j<=wall[i].t;j++)
cnt[j]++;
flag = false;
for(j = wall[i].s;j<=wall[i].t;j++)
{
if(cnt[j]>k)
{
flag = true;
break;
}
}
if(flag)
{
int max = 0;
for(int k = 1;k<=i;k++)
if(wall[k].s<=j&&wall[k].t>=j)
{
if(wall[k].t-j>max)
{
max = wall[k].t-j;
ans = k;
}
}
for(int k = wall[ans].s;k<=wall[ans].t;k++)
cnt[k]--;
sun++;
}
}
printf("%d\n",sun);
}
system("pause");
return 0;
}

```

Followed by: