Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <string>
- #include <set>
- #include <cmath>
- #include <map>
- #include <unordered_map>
- #include <numeric>
- #include <random>
- #include <memory>
- #include <chrono>
- #include <functional>
- #include <unordered_set>
- #include <cstring>
- #include <cassert>
- #include <bitset>
- #ifdef LOCAL
- #include "debug.h"
- #else
- #define debug(x...)
- #endif
- //#define int ll
- //#pragma GCC optimize("Ofast")
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair <int, int> pii;
- #define sz(x) int((x).size())
- #ifndef LOCAL
- mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- #else
- mt19937 rng(228);
- #endif
- const int N = 4e5 + 7;
- const int inf = INT_MAX / 2;
- const ll INF = LLONG_MAX / 3;
- const int MOD = 998244353;
- const ld eps = 1e-6;
- const string cars[] = {"🚗", "🚕", "🚙"};
- typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- int a[N], b[N], c[N], ans[N];
- signed main() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- #endif
- cout << fixed << setprecision(9);
- ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
- int n, flag;
- cin >> n >> flag;
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- if (flag == 1) {
- ordered_set s, t;
- for (int i = 1; i < n; i++) {
- t.insert({ a[i] + i, i });
- }
- cout << t.order_of_key({ a[0], 0 }) + 1 << "\n";
- for (int i = 1; i < n; i++) {
- s.insert({ a[i - 1] - (i - 1), i - 1 });
- t.erase({ a[i] + i, i });
- cout << t.order_of_key({ a[i] + i, -1 }) + s.order_of_key({ a[i] - i, -1 }) + 1 << "\n";
- }
- }
- else {
- for (int i = 0; i < n; i++) {
- int ans = 0;
- for (int d = 0; d <= n; d++) {
- int cur = 1;
- for (int j = 0; j < n; j++) {
- if (abs(i - j) < d) {
- cur += (a[j] < a[i] + abs(i - j));
- }
- else {
- cur += (a[j] < a[i] + d);
- }
- }
- ans = max(ans, cur);
- }
- cout << ans << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement