Submission #1023334

#TimeUsernameProblemLanguageResultExecution timeMemory
1023334ShaShiThe short shank; Redemption (BOI21_prison)C++17
0 / 100
58 ms15312 KiB
#include <bits/stdc++.h> #define int long long // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define F first #define S second #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() #define kill(x) cout << x << "\n", exit(0) #define pii pair<int, int> #define endl "\n" using namespace std; typedef long long ll; typedef long double ld; const int MAXN = (int)1e6 + 7; const int MOD = (int)1e9 + 7; const int INF = (int)1e18 + 7; int n, m, t, tmp, tmp2, tmp3, tmp4, u, v, w, flag, k, q, ans; int arr[MAXN], dp[MAXN], blk[MAXN], par[MAXN], ps[MAXN]; int N, T, D; vector<pii> vec; int32_t main() { #ifdef DEBUG freopen("inp.in", "r", stdin); freopen("res.out", "w", stdout); #else ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif cin >> n >> D >> T; for (int i=1; i<=n; i++) cin >> arr[i]; for (int i=2; i<=n; i++) if (arr[i] <= T && arr[i-1] <= T) arr[i] = min(arr[i], arr[i-1]+1); for (int i=n; i>=1; i--) dp[i] = (arr[i] <= T? 0 : dp[i+1]+1); for (int i=1; i<n; i++) if (arr[i] <= T && arr[i+1] > T) vec.pb(mp(min(T-arr[i], dp[i+1]), i)); sort(all(vec), greater<pii>()); D = min(D, (int)vec.size()); for (int i=0; i<D; i++) blk[vec[i].S] = 1; // for (int i=1; i<=n; i++) cout << arr[i] << " "; // cout << endl; for (int i=1; i<n; i++) if (arr[i] <= T && !blk[i]) arr[i+1] = min(arr[i+1], arr[i]+1); for (int i=1; i<=n; i++) ans += (arr[i] <= T); cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...