Skip to content

Instantly share code, notes, and snippets.

@pureexe
Created August 5, 2013 09:22
Show Gist options
  • Select an option

  • Save pureexe/6154572 to your computer and use it in GitHub Desktop.

Select an option

Save pureexe/6154572 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
using namespace std;
class box
{
public:
int a,w;
box(int c,int v)
{
a=c;
w=v;
}
~box(){};
protected:
private:
};
int main()
{
int s,t,i,n,a,w,u=0,s2=0,t2=0;
vector<class box> Q;
cin >> s >> t >> n;
for(i=0;i<n;i++)
{
cin >> a >> w;
Q.push_back(box(a,w));
}
for(i=0;i<n;i++)
{
if(s-Q[i].a>=0&&t-Q[i].w>=0)
{
s-=Q[i].a;
t-=Q[i].w;
s2+=Q[i].a;
t2+=Q[i].w;
u++;
}
}
cout << u <<"\n" << s2 << "\n" << t2;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment