Submission #1228890

#TimeUsernameProblemLanguageResultExecution timeMemory
1228890Tony_TungRabbit Carrot (LMIO19_triusis)C++17
100 / 100
16 ms4548 KiB
#include <bits/stdc++.h>
#define task ""
#define ll long long
using namespace std;

const int N = 2e5 + 5;
ll a[N], b[N];
vector<int> res;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }

    int n; ll M; cin >> n >> M;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int m = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] <= M*i) b[++m] = M*i-a[i];
    for (int i = 1; i <= m; i++)
    {
        auto it = upper_bound(res.begin(), res.end(), b[i]);
        if (it == res.end()) res.push_back(b[i]);
        else *it = b[i];
    }
    cout << n - res.size();

    return 0;
}

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(task".out", "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...