| ||||||||||
| 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<cstdio>
#include<cstring>
using namespace std;
int a[500008];
int n,m;
int main()
{
scanf("%d%d",&n,&m);
a[1]=n;
int t;
for(int i=1;i<=m;i++)
{
scanf("%d",&t);
if(t==1)
{
scanf("%d",&t);
int k=n-t+1,i;
for(i=1;i<=k;i++)
{
if(t<=a[i])
{
printf("%d\n",i);
a[i+t]=a[i]-t;
a[i]=0;
break;
}
}
if(i>k){puts("0");}
}
else if(t==2)
{
int k;
scanf("%d%d",&k,&t);
/*for(int j=k;j<=k+t;j++)
{
if(a[j]>0)
{
a[k]=max(t,a[j]+j-k);
a[j]=0;
}
}*/
a[k]=t;
if(a[k+t]>0)
{
a[k]+=a[k+t];
a[k+t]=0;
}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator