Submission #575213

# Submission time Handle Problem Language Result Execution time Memory
575213 2022-06-10T02:15:13 Z Bad_day_toCode Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
32 ms 6988 KB
#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;

typedef tree<
    int,
    null_type,
    less_equal<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;

#define ll long long int
#define fo(i, n) for (ll i = 0; i < n; i++)
#define Fo(i, k, n) for (ll i = k; i < n; i++)
#define fvr(it, v) for (auto it = v.rbegin(); it != v.rend(); ++it)
#define ALL(c) (c).begin(), (c).end() // handy for function like "sort()"
#define mod 1000000007
#define ff first
#define ss second
const long long MOD = 998244353;
const long long INF = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vli;
typedef pair<int, int> pii;
long long sq(int x) { return 1ll * x * x; }
const int MAXN = 10001;

// Sieve
ll d[MAXN], divCnt[MAXN];
vector<ll> primes;
void sieve(ll n)
{

    fo(i, n)
    {
        d[i] = i;
    }
    Fo(i, 2, n)
    {
        if (d[i] == i)
            primes.push_back(i);

        for (ll j = 0; j < ((ll)primes.size()) && primes[j] <= d[i] && primes[j] * i < n; j++)
        {
            d[i * primes[j]] = primes[j];
        }
    }
    Fo(i, 2, n)
    {
        ll j = i / d[i];
        divCnt[n] = divCnt[j] + (d[i] != d[j]);
    }
}
// ll primeFactors(ll n)
// {
//     set<ll> factors;
//     while (n != 1)
//     {
//         factors.insert(d[n]);
//         n /= d[n];
//     }
//     return factors.size();
// }
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll a, ll b, ll c)

{
    ll res = 1;
    a = a % c;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a) % c;

        b = b >> 1;
        a = (a * a) % c;
    }
    return res;
}
long long gcd(long long int a, long long int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// int fact[200043];

// void precalc()
// {
//     fact[0] = 1;
//     for (int i = 1; i < 200043; i++)
//         fact[i] = mul(fact[i - 1], i);
// }

// Function to return LCM of two numbers
// int lcm(int a, int b)
// {
//     return (a / gcd(a, b)) * b;
// }
ll inv(ll x, ll c)
{
    return binpow(x, c - 2, c);
}

// int divide(int x, int y, int c)
// {
//     return mul(x, inv(y, c));
// }
// int nCr(int n, int r, int c)
// {
//     return divide(fact[n], mul(fact[r], fact[n - r]), c);
// }
bool cmp1(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first > b.first;
}
bool cmp2(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if (a.second == b.second)
    {
        return a.first < b.first;
    }
    return a.second > b.second;
}
ll find_sum(ll idx, vector<ll> &bit)
{
    ll ans = 0;
    for (; idx > 0; idx -= idx & (-idx))
        ans += bit[idx];
    return ans;
}
void update(ll pos, ll val, vector<ll> &bit)
{
    for (; pos <= bit.size(); pos += pos & (-pos))
    {
        bit[pos] += val;
    }
}

ll longInc(vector<ll>& a){
    ll n=a.size();
    vector<ll> dp(n+1);
    fo(i,n+1)dp[i]=INF;
    dp[0]=0;
    fo(i,n){
        ll p=upper_bound(ALL(dp),a[i])-dp.begin();
        p-=1;
       
        if(dp[p]<=a[i]){
            dp[p+1]=min(dp[p+1],a[i]);
        }
       
    }
    ll idx=0;
    Fo(i,1,n+1){
        if(dp[i]!=INF)idx=i;
    }
    return idx;

}
void solve()
{

    ll n,m;
    cin>>n>>m;
    vector<ll> s(n);
    vector<ll> a;
   
    fo(i,n){
        cin>>s[i];
        if((i+1)*m-s[i]>=0){
            a.push_back((i+1)*m-s[i]);
            
        }
    }
    cout<<n-longInc(a);
  
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, i = 0;
    t = 1;
    // freopen("cowjog.in", "r", stdin);

    // freopen("cowjog.out", "w", stdout);
    // cin >> t;

    while (t--)
    {
        i++;
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Compilation message

triusis.cpp: In function 'void update(long long int, long long int, std::vector<long long int>&)':
triusis.cpp:148:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |     for (; pos <= bit.size(); pos += pos & (-pos))
      |            ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 420 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 420 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 420 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 420 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 416 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 416 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 420 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 420 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 324 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 324 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 22 ms 5452 KB Output is correct
45 Correct 23 ms 3800 KB Output is correct
46 Correct 28 ms 5520 KB Output is correct
47 Correct 32 ms 5464 KB Output is correct
48 Correct 26 ms 6036 KB Output is correct
49 Correct 28 ms 6184 KB Output is correct
50 Correct 31 ms 6252 KB Output is correct
51 Correct 31 ms 6988 KB Output is correct
52 Correct 25 ms 5956 KB Output is correct
53 Correct 15 ms 3044 KB Output is correct
54 Correct 26 ms 6220 KB Output is correct
55 Correct 29 ms 6084 KB Output is correct