# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120754 | InvMOD | Rabbit Carrot (LMIO19_triusis) | C++14 | 37 ms | 7020 KiB |
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
using namespace std;
int lis(vector<int>& potential){
vector<int> lis_;
for(int i = 0; i < (int)potential.size(); i++){
if(!lis_.size()){
lis_.push_back(potential[i]);
}
else{
int p = upper_bound(lis_.begin(), lis_.end(), potential[i]) - lis_.begin();
if(p == lis_.size()){
lis_.push_back(potential[i]);
}
else{
lis_[p] = potential[i];
}
}
}
return lis_.size();
}
void solve()
{
int n,w; cin >> n >> w;
vector<int> potential;
for(int i = 1; i <= n; i++){
int x; cin >> x;
if(x <= 1ll * i * w){
potential.push_back(i * w - x);
}
}
cout << n - lis(potential) <<"\n";
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define name "InvMOD"
if(fopen(name".INP", "r")){
freopen(name".INP", "r", stdin);
freopen(name".OUT", "w", stdout);
}
solve();
return 0;
}
Compilation message (stderr)
# | 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... |