Submission #928264

# Submission time Handle Problem Language Result Execution time Memory
928264 2024-02-16T06:28:20 Z Amr Rabbit Carrot (LMIO19_triusis) C++14
63 / 100
246 ms 18456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
    ll res = 1;
    x = x; // % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res*x)  ; // % mod;
        y = y>>1;
        x = (x*x) ; // % mod;
    }
    return res;
}
ll n , m;
ll a[N];
map<ll,int>  mp;
ll bit[N];
void upd(ll x,ll val)
{
    while(x<=n)
    {
        bit[x] = max(bit[x],val);
        x +=(x&(-x));
    }
    return;
}
ll get(ll x)
{
    ll res = 0;
    while(x> 0)
    {
        res = max(res,bit[x]);
        x-= (x&(-x));
    }
    return res;
}
void solve()
{
    ll ans = 0;
     cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    if(a[1]>m) {ans++,a[1] = m;}
    for(int i = 1; i <= n ;i++){
        a[i] -= (i-1)*m;
        mp[a[i]] = 1;
    }
    ll cnt = 1;
    for(auto it: mp)
        mp[it.first] = cnt++;
    for(int i = n; i>=2; i--)
    {
        ll x = mp[a[i]];
        //cout << x << endl;
        ll y = get(x);
        upd(x,y+1);
    }
    cout << (n-1)-get(mp[a[1]])+ans << endl;




}
int main(){
    //freopen("friday.in","r",stdin);
    //freopen("friday.out","w",stdout);
    fast;
    while(TT--)
        solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2516 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2516 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 2 ms 2680 KB Output is correct
21 Correct 3 ms 2784 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 3 ms 2784 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2480 KB Output is correct
29 Correct 2 ms 2648 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 2 ms 2780 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2680 KB Output is correct
5 Correct 3 ms 2784 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 3 ms 2784 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 2 ms 2648 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2480 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2780 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2516 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 2 ms 2920 KB Output is correct
35 Correct 3 ms 2912 KB Output is correct
36 Correct 2 ms 2908 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 1 ms 2400 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2652 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2920 KB Output is correct
2 Correct 3 ms 2912 KB Output is correct
3 Correct 2 ms 2908 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 1 ms 2400 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 2 ms 2780 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 3 ms 2784 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 3 ms 2784 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2648 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2480 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 1 ms 2652 KB Output is correct
26 Correct 2 ms 2780 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2516 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2648 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2516 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 82 ms 16980 KB Output is correct
45 Correct 246 ms 18364 KB Output is correct
46 Correct 177 ms 18260 KB Output is correct
47 Correct 153 ms 18456 KB Output is correct
48 Correct 58 ms 17132 KB Output is correct
49 Correct 67 ms 17680 KB Output is correct
50 Incorrect 23 ms 4432 KB Output isn't correct
51 Halted 0 ms 0 KB -