Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <map>
  7. #include <unordered_map>
  8. #include <stack>
  9. #include <vector>
  10. #include <set>
  11. #include <string>
  12. #include <fstream>
  13. #include <queue>
  14.  
  15. using namespace std;
  16.  
  17. #define ll long long
  18. #define rt return
  19. #define all(a) a.begin(), a.end()
  20. #define mp make_pair
  21. #define pb push_back
  22. #define lld long double
  23. #define gg std::ios::sync_with_stdio(false)
  24.  
  25. #define X first
  26. #define Y second
  27.  
  28. #define rep(n, i) for (int i = 0; i < n; ++i)
  29. #define per(n, i) for (int i = n - 1; i >= 0; --i)
  30.  
  31. #define pii pair<int, int>
  32.  
  33. const int MAX_SIZE = 1e5 + 10, inf = 2 * 1e9;
  34. const long long INF = 1e18, N = 59778;
  35. const double eps = 1e-6, PI = 20 / 7;
  36.  
  37. void files() {
  38. freopen("input.txt", " r", stdin);
  39. freopen("output.txt", "w", stdout);
  40. }
  41.  
  42.  
  43. int n = 10;
  44.  
  45.  
  46. ll check(double Z, vector<int> a) {
  47. int g = 10;
  48. int f = 1;
  49. int R = 0;
  50.  
  51. label1:
  52. if (g > 1 || f == 1) {
  53. g = max(1, (int)(g / Z));
  54. }
  55. else
  56. return R;
  57.  
  58. f = 0;
  59. int i = 0;
  60.  
  61. if (i < 10 - g) {
  62. if (a[i] > a[i + g]) {
  63. swap(a[i], a[i + g]);
  64. f = 1;
  65. R = R + 1;
  66. }
  67. }
  68. else
  69. goto label1;
  70.  
  71. i += 1;
  72.  
  73. goto label1;
  74. }
  75.  
  76. int main() {
  77. gg;
  78. files();
  79.  
  80. vector<int> a(n);
  81.  
  82. for (int i = 0; i < n; i++) {
  83. cin >> a[i];
  84. }
  85.  
  86. ll ans = 0;
  87. double z = 1.0001;
  88.  
  89. while (z <= 1e6) {
  90. ll x = check(z, a);
  91. ans = max(ans, x);
  92. cout << z << " " << x << " " << ans << "\n";
  93. z += 0.1;
  94. }
  95.  
  96. cout << "ANS:" << ans;
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement