Submission #1105095

#TimeUsernameProblemLanguageResultExecution timeMemory
1105095suraj517Rabbit Carrot (LMIO19_triusis)C++14
100 / 100
30 ms6084 KiB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pdouble(x) fixed<<setprecision(20)<<x
#define inf 1e9
#define inff 1e18
#define vec vector
#define pii pair<int,int>
#define pll pair<long long,long long>
#define maxv(a) *max_element(a.begin(), a.end())
#define minv(a) *min_element(a.begin(), a.end())
#define pb push_back
#define ff first
#define ub upper_bound
#define lb lower_bound
#define ss second
#define YY cout << "YES" << endl
#define NN cout << "NO" << endl
#define C(x) cout << x << endl
#define f(i, a, b) for (int i = a; i < b; i++)
#define rf(i, a, b) for (int i = a - 1; i >= b; i--)
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define google(i, x) cout << "Case #" << i << ": " << x << endl
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

const ll M = 1e9+7;

ll gcd(ll a, ll b) { while (b) {a %= b; swap(a,b);} return a; }
ll lcm(ll a, ll b) { ll g=gcd(a,b); ll res=a*(b/g); return res; }
ll extended_gcd(ll a, ll b, ll &x, ll &y) { if (b==0) { x=1; y=0; return a; } ll x1,y1; ll g=extended_gcd(b,a%b,x1,y1); x=y1; y=x1-y1*(a/b); return g; }
ll binExp(ll a, ll b, ll m=M) { a = a % m; ll res = 1; while (b) { if (b&1) { res=(res * a) % m; } a=(a * a) % m; b>>=1; } return res; }
ll mod_inv(ll a, ll m=M) { a = a % m; return binExp(a,m-2,m); }     // only for prime m
ll mod_add(ll a, ll b, ll m=M) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
ll mod_sub(ll a, ll b, ll m=M) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
ll mod_mul(ll a, ll b, ll m=M) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
ll mod_div(ll a, ll b, ll m=M) { a = a % m; ll binv = mod_inv(b,m); return (((a*binv)%m)+m)%m; }
int test;


void print(auto &a)
{
    for(auto it:a)
    {
        cout<<it<<" ";  
    }
    cout<<endl;
}

/****************************   C..O..D..E   ****************************/

const int N = 1e3+3; 

int fun(vec<int> b)
{
    int n = b.size();
    vec<int> dp;
    f(i,0,n)
    {
        int j = ub(all(dp), b[i]) - dp.begin();
        if(j == dp.size()) dp.pb(b[i]);
        else dp[j] = b[i];
    }
    return dp.size();
}

void solve()
{
    int n,m; cin>>n>>m;
    vec<int> a(n);
    f(i,0,n) cin>>a[i];
    vec<int> b;
    f(i,0,n)
    {
        if((i+1)*m >= a[i])
        {
            b.pb((i+1)*m - a[i]);
        }
    }
    C(n-fun(b));
}   
 

int main()
{
    fast_io;
    // fun();
    int t = 1; 
    // cin>>t;
    test = 1;
    while(t--)
    {
        solve();
        test++;
    }
    return 0;
}

Compilation message (stderr)

triusis.cpp:47:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   47 | void print(auto &a)
      |            ^~~~
triusis.cpp: In function 'int fun(std::vector<int>)':
triusis.cpp:67:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         if(j == dp.size()) dp.pb(b[i]);
      |            ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...