Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool bestTime(const pair<long long,long long> &figure, const pair<long long,long long> &nextFigure) {
- return figure.second < nextFigure.second;
- }
- int main() {
- long long number, idealWeight, timeRemaining;
- cin >> number >> idealWeight >> timeRemaining;
- vector<long long> timeFix(number);
- long long weight;
- for (long long i = 0; i < number; ++i) {
- cin >> weight;
- timeFix[i] = abs(idealWeight - weight);
- }
- vector<pair<long long, long long>> figures;
- for (long long i = 0; i < number; ++i) figures.push_back(make_pair(i + 1, timeFix[i]));
- sort(figures.begin(), figures.end(), bestTime);
- vector<long long> bestFigures;
- for (pair<long long, long long> figure: figures) {
- timeRemaining -= figure.second;
- if (timeRemaining >= 0) bestFigures.push_back(figure.first);
- }
- cout << bestFigures.size() << endl;
- for (long long bestFigure: bestFigures) cout << bestFigure << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement