Submission #946751

# Submission time Handle Problem Language Result Execution time Memory
946751 2024-03-15T03:03:07 Z KK_1729 Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 5468 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"

void printVector(vector<int> a){
    for (auto x: a) cout << x << " ";
    cout << endl;
}

int max(int x, int y){
    if (x > y) return x;
    else return y;
}


void solve(){
    int n, m; cin >> n >> m;
    vector<int> a(n+1);
    FOR(i,1,n+1) cin >> a[i];

    vector<int> b(n+1);
    FOR(i,1,n+1) b[i] = m*i-a[i];

    // printVector(b);
    vector<int> dp(n+1);
    int maxx = 0;
    FOR(i,1,n+1){
        if (b[i] >= 0){
            dp[i] = 1;
            FOR(j,1,i){
                if (b[j] >= 0 && b[j] <= b[i]) dp[i] = max(dp[i], 1+dp[j]);
            }
            maxx = max(maxx, dp[i]);
        }
    }
    
    cout << n-maxx << endl;
    // printVector(dp);
}
int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", stdin)
    int t = 1; // cin >> t;
    while (t--) solve();
}







# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 9 ms 560 KB Output is correct
21 Correct 14 ms 588 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 15 ms 348 KB Output is correct
24 Correct 14 ms 600 KB Output is correct
25 Correct 13 ms 344 KB Output is correct
26 Correct 14 ms 348 KB Output is correct
27 Correct 17 ms 596 KB Output is correct
28 Correct 14 ms 348 KB Output is correct
29 Correct 13 ms 348 KB Output is correct
30 Correct 14 ms 596 KB Output is correct
31 Correct 15 ms 348 KB Output is correct
32 Correct 14 ms 344 KB Output is correct
33 Correct 14 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 14 ms 588 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 15 ms 348 KB Output is correct
8 Correct 14 ms 600 KB Output is correct
9 Correct 13 ms 344 KB Output is correct
10 Correct 14 ms 348 KB Output is correct
11 Correct 17 ms 596 KB Output is correct
12 Correct 14 ms 348 KB Output is correct
13 Correct 13 ms 348 KB Output is correct
14 Correct 14 ms 596 KB Output is correct
15 Correct 15 ms 348 KB Output is correct
16 Correct 14 ms 344 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 456 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 856 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 14 ms 600 KB Output is correct
38 Correct 16 ms 604 KB Output is correct
39 Correct 14 ms 604 KB Output is correct
40 Correct 13 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 16 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 14 ms 600 KB Output is correct
5 Correct 16 ms 604 KB Output is correct
6 Correct 14 ms 604 KB Output is correct
7 Correct 13 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 16 ms 524 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 9 ms 560 KB Output is correct
15 Correct 14 ms 588 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 15 ms 348 KB Output is correct
18 Correct 14 ms 600 KB Output is correct
19 Correct 13 ms 344 KB Output is correct
20 Correct 14 ms 348 KB Output is correct
21 Correct 17 ms 596 KB Output is correct
22 Correct 14 ms 348 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Correct 14 ms 596 KB Output is correct
25 Correct 15 ms 348 KB Output is correct
26 Correct 14 ms 344 KB Output is correct
27 Correct 14 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Execution timed out 1055 ms 5468 KB Time limit exceeded
45 Halted 0 ms 0 KB -