Submission #929091

# Submission time Handle Problem Language Result Execution time Memory
929091 2024-02-17T17:09:44 Z Karoot Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
94 ms 16864 KB
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>

#define all(x)  (x).begin(), (x).end()
#define rall(x)  (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;

ll linf = 1e15+1;

inline void scoobydoobydoo(){
    ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}

int main(){
    scoobydoobydoo();
    ll n, M; cin >> n >> M;
    vector<ll> v(n);
    vector<ll> filtered;
    for (int i = 0; i < n; i++){
        cin >> v[i];
        if (v[i] <= M*(i+1))filtered.push_back(-v[i]+M*(i+1));
    }

    set<pair<ll, ll> > s; //value, dp

    ll dp[200001];

    if (filtered.size() == 0){
        cout << n << endl;
        return 0;
    }

    dp[0] = 1;
    s.insert({0, 0});
    s.insert({filtered[0], 1});
    for (int i = 1; i < filtered.size(); i++){
        auto it = s.upper_bound({filtered[i], 10000000});
        it--;
        dp[i] = (*it).second + 1;
        if ((*it).first == filtered[i])s.erase(it);
        s.insert({filtered[i], dp[i]});

        while (true){
            auto itr = s.find({filtered[i], dp[i]});
            itr++;
            if (itr == s.end())break;
            if ((*itr).second > dp[i])break;
            s.erase(itr);
        }
    
    }


    cout << n - (*s.rbegin()).second << endl;






    return 0;
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:49:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for (int i = 1; i < filtered.size(); i++){
      |                     ~~^~~~~~~~~~~~~~~~~
# 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 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 1 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 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 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 1 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 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 652 KB Output is correct
21 Correct 2 ms 720 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 708 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 2 ms 856 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 2 ms 860 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 1 ms 760 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 652 KB Output is correct
5 Correct 2 ms 720 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 708 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 1 ms 760 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 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 1 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 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 1 ms 600 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 1 ms 856 KB Output is correct
41 Correct 1 ms 464 KB Output is correct
42 Correct 1 ms 584 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 856 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 604 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 1 ms 652 KB Output is correct
15 Correct 2 ms 720 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 708 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 2 ms 856 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 760 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 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 1 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 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 89 ms 16336 KB Output is correct
45 Correct 21 ms 3932 KB Output is correct
46 Correct 49 ms 4824 KB Output is correct
47 Correct 44 ms 4964 KB Output is correct
48 Correct 60 ms 14740 KB Output is correct
49 Correct 94 ms 16864 KB Output is correct
50 Correct 25 ms 6104 KB Output is correct
51 Correct 27 ms 5456 KB Output is correct
52 Correct 69 ms 10700 KB Output is correct
53 Correct 13 ms 3160 KB Output is correct
54 Correct 82 ms 13552 KB Output is correct
55 Correct 79 ms 13604 KB Output is correct