#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 550;
int n, d, T, t[maxn], r[maxn], qtd[maxn];
set<pair<int,int>> st;
void solve() {
cin >> n >> d >> T;
d = min(d,n-1);
int ans = 0;
for(int i = 1; i <= n; i++) cin >> t[i];
for(int i = 1; i <= n; i++) {
r[i] = 0;
for(int j = i; j >= 1; j--) {
if(t[j]-j <= T-i) {
r[i] = j;
break;
}
}
if(r[i]!=0) ans++;
// cout << i << " " << r[i] << endl;
}
//qtd[i] -> qtd de retas passando de i+1 pra i
for(int i = 1; i < n; i++) {
qtd[i] = 0;
for(int j = i+1; j <= n; j++) {
if(r[j] != 0 && r[j] <= i) qtd[i]++;
}
st.insert(mp(qtd[i],i));
// cout << i << " - " << qtd[i] << endl;
}
while(d--) {
auto it = st.end(); it--;
int id = it->sc;
st.erase(it);
//tira todos os j que tem r[j] <= id
for(int j = id+1; j <= n; j++) {
if(r[j] != 0 && r[j] <= id) {
//diminui a qtd dos que ele tinha aumentado
for(int i = r[j]; i < j; i++) {
st.erase(mp(qtd[i],i));
qtd[i]--;
st.insert(mp(qtd[i],i));
}
r[j] = 0;
ans--;
}
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
260 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |