You are viewing a single comment's thread. Return to all comments →
using namespace std; int main() { int g; cin>>g; while(g--) { int n,m,x,y; long int s=0; cin>>n>>m>>x; int c[n],d[m]; for(int i=0;i>c[i];
} for(int i=0;i<m;i++) { cin>>d[i]; } int i=0,j=0,k=0; while(s<=x&&(i<=n-1||j<=m-1)) { if(i<=n-1&&j<=m-1) {if(c[i]<d[j]) {s+=c[i];i++; } else { s+=d[j]; j++; } } else {if(i>=n) { s+=d[j++]; } else if(j>=m) { s+=c[i++]; } } k++; } cout<<k-1<<endl; s=0; }
} can any tell mistake in this program?
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
include
include
using namespace std; int main() { int g; cin>>g; while(g--) { int n,m,x,y; long int s=0; cin>>n>>m>>x; int c[n],d[m]; for(int i=0;i>c[i];
} can any tell mistake in this program?