Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int l, r;
- cin >> l >> r;
- if (l == 0 && r == 0)
- cout << "Not a moose\n";
- else if (l == r)
- cout << "Even " << l * 2 << '\n';
- else
- cout << "Odd " << max(l, r) * 2 << '\n';
- return 0;
- }
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- struct runner {
- string name;
- double a, b;
- bool operator<(const runner& other) const {
- return b < other.b;
- }
- };
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n;
- cin >> n;
- vector<runner> runners;
- for (int i = 0; i < n; ++i) {
- double a, b;
- string name;
- cin >> name >> a >> b;
- runners.push_back({ name, a, b });
- }
- double res = 80;
- vector<string> names(4);
- sort(runners.begin(), runners.end());
- for (int i = 0; i < n; ++i) {
- double time = runners[i].a;
- int num_runners = 1;
- for (int j = 0; num_runners < 4 && j < n; ++j) {
- if (i == j)
- continue;
- time += runners[j].b;
- ++num_runners;
- }
- if (time < res) {
- res = time;
- names[0] = runners[i].name;
- num_runners = 1;
- for (int j = 0; num_runners < 4 && j < n; ++j) {
- if (i == j)
- continue;
- names[num_runners++] = runners[j].name;
- }
- }
- }
- cout << res << '\n';
- for (string name : names)
- cout << name << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement