Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <stack>
- #include <bits/stdc++.h>
- #include <vector>
- #include <bitset>
- #define rep(a,b,c) for(a = b; a <= c; ++a)
- #define pob pop_back
- #define pof pop_front
- #define pub push_back
- #define f first
- #define s second
- #define ll long long int
- #define nmax 200001
- #define mod 998244353
- using namespace std;
- ifstream f("tabel.in");
- ofstream g("tabel.out");
- bool sortat = 0;
- int main()
- {
- int maxim, n, m, contor = 0, sum = 0, copasum, v[101], i, j;
- cin >> n >> m;
- for(i = 1; i <= n; ++i)
- {
- cin >> v[i];
- sum += v[i];
- if(sum <= m)
- {
- cout << 0 << ' ';
- }
- else
- {
- copasum = sum;
- sortat = 0;
- contor = 0;
- sort(v + 1, v + i);
- for(j = i - 1; j >= 1 && copasum > m; --j)
- {
- copasum -= v[j];
- ++contor;
- }
- cout << contor << ' ';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement