Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int main()
- {
- int s,n,i=1,a,b=0;
- ifstream fin("psp.in");
- ofstream fout("psp.out");
- fin>>n;//jocuri primite
- fin>>s;
- while(i<=n)
- {
- fin>>a;
- if(s-a>=0)
- {
- s=s-a;
- b++;
- }
- i++;
- }
- fout<<b<<" "<<s;
- fin.close();
- fin.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement