# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676748 | asteilind | Rabbit Carrot (LMIO19_triusis) | C++17 | 1084 ms | 3796 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 <iostream>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <set>
#include <numeric>
#include <bitset>
#include <climits>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define MOD 1000000007
using namespace std;
void setIO(string name = "") { // name is nonempty for USACO file I/O
ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
if(name.length()){
freopen((name+".in").c_str(), "r", stdin); // see Input & Output
freopen((name+".out").c_str(), "w", stdout);
}
}
void solve()
{
ll n; cin >> n; ll ju; cin >> ju;
vector<ll> poles(n+1);
vector<ll> dp(n+1,0);
poles[0] = 0;
forn(i,n)
{
cin >> poles[i+1];
}
dp[0] = 1;
ll maxv = 1;
for (int i=1 ; n>=i ; i++)
{
for (int j=0 ; i>j ; j++)
{
if (dp[j] != 0 && poles[i]-poles[j] <= (i-j)*ju)
{
dp[i] = max(dp[i],dp[j]+1);
maxv = max(dp[i],maxv);
}
}
}
cout << (n+1)-maxv << endl;
}
int main()
{
setIO();
solve();
}
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... |