Advertisement
aayyk

Untitled

Apr 10th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <queue>
  7. #include <stack>
  8. #include <climits>
  9. #include <string>
  10. #include <set>
  11. #include <cmath>
  12. #include <map>
  13. #include <unordered_map>
  14. #include <numeric>
  15. #include <random>
  16. #include <memory>
  17. #include <chrono>
  18. #include <functional>
  19. #include <unordered_set>
  20. #include <cstring>
  21. #include <cassert>
  22. #include <bitset>
  23. #ifdef LOCAL
  24. #include "debug.h"
  25. #else
  26. #define debug(x...)
  27. #endif
  28. //#define int ll
  29. //#pragma GCC optimize("Ofast")
  30.  
  31. #include <ext/pb_ds/assoc_container.hpp>
  32. #include <ext/pb_ds/tree_policy.hpp>
  33. using namespace __gnu_pbds;
  34.  
  35. using namespace std;
  36. typedef long long ll;
  37. typedef long double ld;
  38. typedef pair <int, int> pii;
  39. #define sz(x) int((x).size())
  40.  
  41. #ifndef LOCAL
  42.     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  43. #else
  44.     mt19937 rng(228);
  45. #endif
  46.  
  47. const int N = 4e5 + 7;
  48. const int inf = INT_MAX / 2;
  49. const ll INF = LLONG_MAX / 3;
  50. const int MOD = 998244353;
  51. const ld eps = 1e-6;
  52. const string cars[] = {"🚗", "🚕", "🚙"};
  53.  
  54. typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
  55.  
  56. int a[N], b[N], c[N], ans[N];
  57.  
  58. signed main() {
  59. #ifdef LOCAL
  60.     freopen("input.txt", "r", stdin);
  61.     //freopen("output.txt", "w", stdout);
  62. #endif
  63.     cout << fixed << setprecision(9);
  64.     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  65.  
  66.     int n, flag;
  67.     cin >> n >> flag;
  68.  
  69.     for (int i = 0; i < n; i++) {
  70.         cin >> a[i];
  71.     }
  72.  
  73.     if (flag == 1) {
  74.         ordered_set s, t;
  75.  
  76.         for (int i = 1; i < n; i++) {
  77.             t.insert({ a[i] + i, i });
  78.         }
  79.         cout << t.order_of_key({ a[0], 0 }) + 1 << "\n";
  80.  
  81.         for (int i = 1; i < n; i++) {
  82.             s.insert({ a[i - 1] - (i - 1), i - 1 });
  83.             t.erase({ a[i] + i, i });
  84.  
  85.             cout << t.order_of_key({ a[i] + i, -1 }) + s.order_of_key({ a[i] - i, -1 }) + 1 << "\n";
  86.         }
  87.  
  88.     }
  89.     else {
  90.         for (int i = 0; i < n; i++) {
  91.             int ans = 0;
  92.             for (int d = 0; d <= n; d++) {
  93.                 int cur = 1;
  94.                 for (int j = 0; j < n; j++) {
  95.                     if (abs(i - j) < d) {
  96.                         cur += (a[j] < a[i] + abs(i - j));
  97.                     }
  98.                     else {
  99.                         cur += (a[j] < a[i] + d);
  100.                     }
  101.                 }
  102.                 ans = max(ans, cur);
  103.             }
  104.             cout << ans << "\n";
  105.         }
  106.     }
  107.  
  108.     return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement