Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(NULL);
  7.  
  8. int l, r;
  9. cin >> l >> r;
  10.  
  11. if (l == 0 && r == 0)
  12. cout << "Not a moose\n";
  13. else if (l == r)
  14. cout << "Even " << l * 2 << '\n';
  15. else
  16. cout << "Odd " << max(l, r) * 2 << '\n';
  17. return 0;
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. #include <iostream>
  34. #include <vector>
  35. #include <algorithm>
  36. using namespace std;
  37.  
  38. struct runner {
  39. string name;
  40. double a, b;
  41. bool operator<(const runner& other) const {
  42. return b < other.b;
  43. }
  44. };
  45.  
  46. int main() {
  47. ios_base::sync_with_stdio(false);
  48. cin.tie(NULL);
  49.  
  50. int n;
  51. cin >> n;
  52. vector<runner> runners;
  53. for (int i = 0; i < n; ++i) {
  54. double a, b;
  55. string name;
  56. cin >> name >> a >> b;
  57. runners.push_back({ name, a, b });
  58. }
  59.  
  60. double res = 80;
  61. vector<string> names(4);
  62. sort(runners.begin(), runners.end());
  63. for (int i = 0; i < n; ++i) {
  64. double time = runners[i].a;
  65. int num_runners = 1;
  66. for (int j = 0; num_runners < 4 && j < n; ++j) {
  67. if (i == j)
  68. continue;
  69. time += runners[j].b;
  70. ++num_runners;
  71. }
  72. if (time < res) {
  73. res = time;
  74. names[0] = runners[i].name;
  75. num_runners = 1;
  76. for (int j = 0; num_runners < 4 && j < n; ++j) {
  77. if (i == j)
  78. continue;
  79. names[num_runners++] = runners[j].name;
  80. }
  81. }
  82. }
  83.  
  84. cout << res << '\n';
  85. for (string name : names)
  86. cout << name << '\n';
  87.  
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement