eolymp
bolt
Try our new interface for solving problems
published at 3/25/24, 5:33:55 pm

include <iostream>

include <vector>

include <algorithm>

using namespace std;

int main() { int n, k; cin >> n >> k;

vector<int> m(n);
for (int i = 0; i < n; i++)
    cin >> m[i];
sort(m.begin(), m.end());
int res = 0;
int a = 0, b = m.size() - 1;
if (m[b] > k) {
    cout << "Impossible" << endl; 
    return 0;
}
while (a <= b) {
    if (m[a] + m[b] > k) 
        b--;
    else { 
        a++; 
        b--; 
    }
    res++;
}
cout << res << endl;

return 0;

}