Submission #654261

#TimeUsernameProblemLanguageResultExecution timeMemory
654261baneRabbit Carrot (LMIO19_triusis)C++17
100 / 100
37 ms7580 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define ite( x, n) for (int i = x; i<n; i++)
#define jte( x, n) for (int j = x; j<n; j++)
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define fr first
#define sc second
#define mp make_pair

void setIO(string name = "") {
    cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
ll inf = 100000000;
int MOD = 1e9 + 7;
int main() {
    setIO();
    int n,m;
    cin >> n >> m;
    vector<ll>a(n);
    vector<ll>b(n);
    ite(0,n){
        cin >> a[i];
        b[i] = m*(i + 1) - a[i];
    }
    vector<ll>dp;
    for (auto e : b){
        if (e < 0)continue;
        auto it = upper_bound(dp.begin(), dp.end(), e);
        if (it == dp.end()){
            dp.pb(e);
        }else *it = e;
    }
    cout<<n - dp.size();
    return 0;
}

Compilation message (stderr)

triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...