제출 #1311082

#제출 시각아이디문제언어결과실행 시간메모리
1311082tkhoi13Rabbit Carrot (LMIO19_triusis)C++20
0 / 100
2 ms576 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define db double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define szx(x) ((int)(x).size())
#define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; ++i)
#define ROF(i, a, b) for (int i = a, _b = (b); i >= _b; --i)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define endl '\n'
#define inf 1000000007
#define mod 1000000007
// #define mod 998244353

using namespace std;
using namespace __gnu_pbds;

void setIO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
}
void openFile(string filename = "") {
    if (!filename.empty())
        if (ifstream(filename + ".in")) {
            freopen((filename + ".in").c_str(), "r", stdin);
            freopen((filename + ".out").c_str(), "w", stdout);
        }
}
ll binpow(ll a, ll b, int m = mod) {
    ll res = 1;
    a %= m;
    while (b) {
        if (b & 1) res = (a * res) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}
const int FMAX = 2e5 + 5;
ll fact[FMAX], invf[FMAX];
void process() {
    fact[1] = fact[0] = invf[1] = invf[0] = 1;
    FOR(i, 2, FMAX - 1) fact[i] = (fact[i - 1] * i) % mod;
    invf[FMAX - 1] = binpow(fact[FMAX - 1], mod - 2, mod);
    ROF(i, FMAX - 1, 1) invf[i - 1] = invf[i] * i % mod;
}
ll comb(int a, int b) {
    b = min(b, a - b);
    if (a < 0 || b < 0) return 0;
    return fact[a] * (invf[b] * invf[a - b] % mod) % mod;
}
const int PMAX = 1e6 + 5;
bool prime[PMAX + 1];
void sieve() {
    fill(prime, prime + PMAX + 1, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i * i <= PMAX; i++) {
        if (prime[i] == 0) continue;
        prime[i] = 1;
        for (ll j = i * i; j <= PMAX; j += i) prime[j] = 0;
    }
}
struct DSU {
    vector<int> comp;
    ll ans = 0;
    DSU(int n) { comp.assign(n + 5, -1); }

    int find(int v) { return comp[v] < 0 ? v : comp[v] = find(comp[v]); }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (comp[u] > comp[v]) swap(u, v);
        comp[u] += comp[v];
        comp[v] = u;
    }

    int getsz(int v) { return -comp[find(v)]; }
    bool same(int u, int v) { return find(u) == find(v); }
};

const int MAX = 2e5 + 5;
int n, m;
ll a[MAX];
void solve() {
    vector<ll> b;
    REP(i, n) if ((i + 1) * m - a[i] >= 0) b.pb((i + 1) * m - a[i]);
    vector<ll> d;
    REP(i, szx(b)) {
        auto x = lower_bound(all(d), b[i]);
        if (x == d.end())
            d.pb(b[i]);
        else
            *x = b[i];
    }

    cout << n - szx(d);
}

void input() {
    cin >> n >> m;
    REP(i, n) cin >> a[i];
}

void preprocess() { input(); }

int main() {
    setIO();
    openFile("main");
    int t = 1;
    // cin >> t;
    preprocess();
    while (t--) { solve(); }
}

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'void openFile(std::string)':
triusis.cpp:32:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             freopen((filename + ".in").c_str(), "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:33:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             freopen((filename + ".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...