# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426253 | Amylopectin | Journey (NOI18_journey) | C++14 | 368 ms | 47792 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 <stdio.h>
using namespace std;
const long long mxn = 1e4 + 10,mxm = 410,mxi = 5e8 + 1;
struct pat
{
long long to,tim;
};
struct pat pa[mxn][mxm] = {};
long long dp[mxm][mxn] = {};
int main()
{
long long i,j,n,m,h,f,t,cti,k,o,fn;
scanf("%lld %lld %lld",&n,&m,&h);
for(i=0; i<n-1; i++)
{
for(j=0; j<h; j++)
{
scanf("%lld %lld",&t,&cti);
pa[i][j] = {t,cti};
}
}
dp[0][0] = 1;
for(i=0; i<m; i++)
{
for(j=0; j<n-1; j++)
{
if(i > 0)
dp[i][j] += dp[i-1][j];
if(dp[i][j] > mxi)
{
dp[i][j] = mxi;
}
for(k=0; k<h; k++)
{
fn = pa[j][k].to;
cti = pa[j][k].tim;
if(i + cti < m && fn > j)
{
dp[i+cti][fn] += dp[i][j];
if(dp[i+cti][fn] > mxi)
{
dp[i+cti][fn] = mxi;
}
}
}
}
// if(i > 0)
// {
// dp[i][n-1] += dp[i-1][n-1];
// }
printf("%lld\n",dp[i][n-1]);
}
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... |