Pagini recente » Statistici Mihai Preguza (Radioactiv) | Statistici Stoian Matei Octavian (MateiStoian) | Diferente pentru home intre reviziile 840 si 902 | Diferente pentru utilizator/popoiu.george intre reviziile 64 si 42 | Cod sursa (job #541753)
Cod sursa(job #541753)
#include<fstream>
using namespace std;
int v[2000][2000],k[3000],n,m,mx;
ifstream in("walls.in");
int caut(int x)
{int i;
for(i=1;i<=n;i++)
{if(k[i]>=x)
return i-1;}
return n;
}
int max(int a,int b)
{if(a>b) return a;return b;}
void diag()
{int i,x,y,j,h,p;
in>>m;
ofstream out("walls.out");
for(i=0;i<m;i++)
{in>>x>>y;
j=caut(x);
y--;
if(y>mx)
out<<"MISS";
else
{for(h=j;h>=0;h--)
if(v[h][y])
{v[h][y]--;
break;}
out<<"HIT "<<v[h][y]+k[h]+1<<" "<<h+1;
/*if(v[h][y+1]==0)
out<<" YES";
else*/
if(v[h][y]==0)
{out<<" YES";
for(p=y+1;v[h][p]&&p<=1999;p++)
v[h][p]=0;
}
else
out<<" NO";
}
out<<'\n';
}
}
void citire()
{int i,j,x,y;
in>>n;
for(i=0;i<n;i++)
{in>>x>>y;
mx=max(mx,y);
k[i+1]=k[i]+x+1;
for(j=0;j<y;j++)
v[i][j]=x;
}
}
int main()
{citire();
diag();
return 0;
}