Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm> //Pentru functia sort
- using namespace std;
- int main()
- {
- ifstream fin("masini.in");
- ofstream fout("masini.out");
- int n, a[1000], s = 0, cnt = 0, T;
- fin>>n>>T;
- for(int i = 0; i < n; i++)
- fin>>a[i];
- sort(a, a + n);
- for(int i = 0; i < n; i++)
- {
- s += a[i];
- if(s <= T)
- cnt++;
- else
- break;
- }
- fout<<cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement