Submission #866765

# Submission time Handle Problem Language Result Execution time Memory
866765 2023-10-27T03:15:58 Z tienbinh Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
23 ms 6344 KB
#include <bits/stdc++.h>

using namespace std;
#define name ""
#define all(x) x.begin(), x.end()
const int N = 1e5 + 7;
long long  b[N], M, a[N];
using ll = long long;
int n;
basic_string <ll> compress, v;
struct BIT{
    long long bit[N];
    BIT() {memset(bit, 0, sizeof bit);}
    void upd(int x, long long val){
        for(; x < N ; x += (x & - x)) bit[x] = max(bit[x], val);
    }
    long long get(int x){
        long long ans = 0;
        for(; x >= 1; x -= (x & - x)) ans = max(ans, bit[x]);
        return ans;
    }
}bit;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if(fopen("bug.inp", "r"))
        freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout);
    else if (fopen(name".inp", "r"))
        freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
    cin >> n >> M;
    for(int i = 1; i <= n ; i++){
        cin >> a[i];
        if(i * M >= a[i]) v += (i * M - a[i]), compress += (i * M - a[i]);
    }
    sort(all(compress));
    compress.erase(unique(all(compress)), compress.end());
    for(int i = 0; i < v.size() ; i++)
        v[i] = lower_bound(all(compress), v[i]) - compress.begin() + 1;
//    for(int it : v)
//        cout << it <<" ";
//    cout << "\n";
    long long ans = 0;
    for(int it : v){
        long long tmp = bit.get(it) + 1;
        ans  = max(ans, tmp);
        bit.upd(it, tmp);
    }
    cout << n - ans;
    return 0;
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < v.size() ; i++)
      |                    ~~^~~~~~~~~~
triusis.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:28:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout);
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:30:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 0 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 0 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2808 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 2 ms 2684 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2652 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 2 ms 2676 KB Output is correct
31 Correct 1 ms 2648 KB Output is correct
32 Correct 2 ms 2656 KB Output is correct
33 Correct 1 ms 2704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2808 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2684 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 2 ms 2676 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 2 ms 2656 KB Output is correct
17 Correct 1 ms 2704 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 1 ms 2648 KB Output is correct
25 Correct 1 ms 2652 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2652 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 0 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2748 KB Output is correct
37 Correct 1 ms 2656 KB Output is correct
38 Correct 1 ms 2652 KB Output is correct
39 Correct 1 ms 3104 KB Output is correct
40 Correct 2 ms 2700 KB Output is correct
41 Correct 1 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2748 KB Output is correct
4 Correct 1 ms 2656 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 3104 KB Output is correct
7 Correct 2 ms 2700 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2808 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2684 KB Output is correct
19 Correct 1 ms 2648 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 2 ms 2676 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 2 ms 2656 KB Output is correct
27 Correct 1 ms 2704 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 1 ms 2652 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
40 Correct 0 ms 2652 KB Output is correct
41 Correct 1 ms 2652 KB Output is correct
42 Correct 1 ms 2652 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Incorrect 23 ms 6344 KB Output isn't correct
45 Halted 0 ms 0 KB -