#include #include #include #include #include #include using namespace std; typedef vector array; typedef pair point; typedef set potential; int solve(const array &accel, int x20, int v0) { potential pot; queue toBeProcessed; toBeProcessed.push(point(x20,v0)); while (!toBeProcessed.empty()){ point po = toBeProcessed.front(); toBeProcessed.pop(); if ( pot.count(po)>0 ) continue; pot.insert(po); int cx2=po.first; int cv = po.second; for ( array::const_iterator it=accel.begin() ; it!=accel.end() ; ++it ){ int a = *it; int nv = cv+*it; int nx2 = cx2 + cv*2 + a; if ( nv<=0 && 0<=nx2 ) toBeProcessed.push(point(nx2,nv)); } } for ( int x2=0 ; x20 ) return x2; } return -1; } int main(void) { int ncases; cin>>ncases; for ( int ci=0 ; ci0 ) cout<>na; for ( int i=0 ; i>a; accel.push_back(a); } sort(accel.begin(), accel.end()); int nq; cin>>nq; for ( int i=0 ; i>x20>>v0; x20*=2; v0=-v0; if ( v0*v0 > x20*accel.back() ) { cout<<"crash"<