fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdio>
  4. #include <iomanip>
  5. #include <sstream>
  6. #include <cstring>
  7. #include <string>
  8. #include <cmath>
  9. #include <stack>
  10. #include <list>
  11. #include <queue>
  12. #include <deque>
  13. #include <set>
  14. #include <map>
  15. #include <vector>
  16. #include <algorithm>
  17. #include <numeric>
  18. #include <utility>
  19. #include <functional>
  20. #include <limits>
  21. using namespace std;
  22.  
  23. typedef long long ll;
  24. typedef unsigned long long ull;
  25. typedef unsigned int ui;
  26. typedef pair<int,int> pii;
  27. typedef vector<vector<int> > graph;
  28.  
  29. const double pi = acos(-1.0);
  30.  
  31. #define oned(a, x1, x2) { cout << #a << ":"; for(int _i = (x1); _i < (x2); _i++){ cout << " " << a[_i]; } cout << endl; }
  32. #define twod(a, x1, x2, y1, y2) { cout << #a << ":" << endl; for(int _i = (x1); _i < (x2); _i++){ for(int _j = (y1); _j < (y2); _j++){ cout << (_j > y1 ? " " : "") << a[_i][_j]; } cout << endl; } }
  33.  
  34. #define mp make_pair
  35. #define pb push_back
  36. #define fst first
  37. #define snd second
  38.  
  39. const int MAXN = 100005;
  40.  
  41. int n, a[MAXN], p[MAXN], cnt[MAXN];
  42.  
  43. void solve() {
  44. sort(a,a+n);
  45. int k = 0;
  46. for(int i = 0; i < n; ) {
  47. int j = i;
  48. while(j<n && a[i]==a[j]) {
  49. j++;
  50. }
  51. p[k] = a[i];
  52. cnt[k] = j-i;
  53. k++;
  54. i = j;
  55. }
  56. bool mirko = true;
  57. int l = 0, r = k-1;
  58. while(r-l > 1) {
  59. int d = min(cnt[l]-1,cnt[r]-1);
  60. cnt[l+1] += d;
  61. cnt[l] -= d;
  62. cnt[r-1] += d;
  63. cnt[r] -= d;
  64. if(mirko) {
  65. cnt[l]--;
  66. cnt[l+1]++;
  67. if(cnt[l]==0) {
  68. l++;
  69. }
  70. } else {
  71. cnt[r]--;
  72. cnt[r-1]++;
  73. if(cnt[r]==0) {
  74. r--;
  75. }
  76. }
  77. mirko = !mirko;
  78. }
  79. if(mirko) {
  80. printf("Slavko\n");
  81. } else {
  82. printf("Mirko\n");
  83. }
  84. printf("%d %d\n", p[l], p[r]);
  85. }
  86.  
  87. int main() {
  88. // freopen("B.in", "r", stdin);
  89. while(scanf("%d", &n)==1) {
  90. for(int i = 0; i < n; i++) {
  91. scanf("%d", a+i);
  92. }
  93. solve();
  94. }
  95. }
  96.  
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
Standard output is empty