Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created December 12, 2014 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/e3525c46e948678a3a7f to your computer and use it in GitHub Desktop.
Save ik11235/e3525c46e948678a3a7f to your computer and use it in GitHub Desktop.
class BuyingTshirts {
public:
int meet(int T, vector<int> Q, vector<int> P) {
int ans=0;
int qq=0;
int pp=0;
for(int i=0;i<Q.size();i++)
{
qq+=Q[i];
pp+=P[i];
if(pp>=T && qq>=T)
ans++;
if(pp>=T)
pp-=T;
if(qq>=T)
qq-=T;
}
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment