Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- int N, Q;
- cin >> N >> Q;
- int *array = new int[N];
- for (int i = 0; i < N; i++)
- {
- cin >> array[i];
- }
- sort(array, array + N);
- //for (int i = 0; i < N; i++)
- //{
- // cout << array[i] << " ";
- //}
- int k = 0;
- int j = 0;
- for (int i = 0; i < N; i++)
- {
- if (array[N - i - 1] = Q)
- k++;
- else
- if (array[N - i - 1] < Q)
- {
- if ((N - i - 1) != j)
- {
- if (array[N - i - 1] + array[j] <= Q)
- {
- k++;
- j++;
- }
- else
- k++;
- }
- else
- k++;
- }
- }
- cout << k;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement