Submission #492257

# Submission time Handle Problem Language Result Execution time Memory
492257 2021-12-06T09:56:26 Z leu_naut Rabbit Carrot (LMIO19_triusis) C++11
0 / 100
0 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define FORd(i,a,b) for (int i = a; i >= b; --i)
#define f first
#define s second
#define FastIO ios_base::sync_with_stdio(0); cin.tie(0);
#define ii pair <int,int>
#define pii pair <ll,ll>
#define all(x) x.begin(), x.end()

const int N = 2e5;
const ll MOD = 1e9 + 7;
const ll base = 31;
const ll oo = 1e18;

ll a[N + 5], b[N + 5];

int main()
{
    /*freopen("pcb.in", "r", stdin);
    freopen("pcb.out", "w", stdout); */
    FastIO
    ll n,m;
    cin >> n >> m;
    FOR(i,1,n) {
        cin >> a[i];
        if (i * m >= a[i - 1]) b[i] = -a[i] + m * i;
    }
    vector <ll> lis;
    FOR(i,1,n)
    {
        if (b[i] < 0) continue;
        int pos = upper_bound(lis.begin(), lis.end(), b[i]) - lis.begin();
        if (pos == lis.size()) lis.push_back(b[i]);
        else lis[pos] = b[i];
    }
    cout << n - lis.size();
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (pos == lis.size()) lis.push_back(b[i]);
      |             ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -