This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define fi first
#define se second
using namespace std;
const int N = 3e5 + 4;
const int oo = 1e18;
const int mod = 1e9 + 7;
int t, n, q, m, k = 0, ans = 0, a[N];
vector<int>v, vi;
void solve(){
cin >> n >> k;
for (int i = 0; i < n; i++){
cin >> a[i];
if ((i + 1) * k >= a[i])vi.push_back((i + 1) * k - a[i]);
}
for (int i = 0; i < vi.size(); i++){
m = upper_bound(v.begin(), v.end(), vi[i]) - v.begin();
if (m == v.size())v.push_back(vi[i]);
else v[m] = vi[i];
}
cout << n - v.size();
}
main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
//freopen("cowjog.in", "r", stdin); freopen("cowjog.out", "w", stdout);
t = 1;
//cin >> t;
while (t--)solve();
return 0;
}
Compilation message (stderr)
triusis.cpp: In function 'void solve()':
triusis.cpp:19:23: 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]
19 | for (int i = 0; i < vi.size(); i++){
| ~~^~~~~~~~~~~
triusis.cpp:21:15: 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]
21 | if (m == v.size())v.push_back(vi[i]);
| ~~^~~~~~~~~~~
triusis.cpp: At global scope:
triusis.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |