Submission #672808

#TimeUsernameProblemLanguageResultExecution timeMemory
672808vjudge1The short shank; Redemption (BOI21_prison)C++11
0 / 100
91 ms21280 KiB
/*#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")*/
#include <bits/stdc++.h>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define N (ll)((ll)2e6+5)
#define M ((ll)998244353)
#define fi first
#define se second
#define bs 2097151ll
ll n, t, m, l[N], a[N];
vector<pair<ll, ll>> v;
vector<ll> u; 
inline bool cmp(ll x, ll y) { return x > y; }
int32_t main() {
#define int ll
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> t; v = { {0, n + 1} };
	for (int i = 1; i <= n; i++) {
		cin >> l[i], l[i] = min(n, max(i - 1, i + t - l[i]));
		v.push_back({ i, l[i] });
		while (v.back().second < i) v.pop_back();
		if(l[i] < i) a[v.back().fi]++;
	}
	for (int i = 1; i <= n; i++) u.push_back(a[i]); sort(u.begin(), u.end(), cmp);
	for (int i = 0; i < m; i++) n -= u[i]; n -= a[0]; cout << n;
}

Compilation message (stderr)

prison.cpp: In function 'int32_t main()':
prison.cpp:28:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   28 |  for (int i = 1; i <= n; i++) u.push_back(a[i]); sort(u.begin(), u.end(), cmp);
      |  ^~~
prison.cpp:28:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |  for (int i = 1; i <= n; i++) u.push_back(a[i]); sort(u.begin(), u.end(), cmp);
      |                                                  ^~~~
prison.cpp:29:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |  for (int i = 0; i < m; i++) n -= u[i]; n -= a[0]; cout << n;
      |  ^~~
prison.cpp:29:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   29 |  for (int i = 0; i < m; i++) n -= u[i]; n -= a[0]; cout << n;
      |                                         ^
#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...