# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586478 | hibiki | Journey (NOI18_journey) | C++11 | 61 ms | 22216 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>
using namespace std;
#define MX 500000001
#define pb push_back
#define f first
#define s second
int n,m,h;
vector<pair<int,int> > v[10005];
int dp[10005][505];
int main()
{
scanf("%d %d %d",&n,&m,&h);
for(int i = 0; i < n - 1; i++)
{
for(int j = 0; j < h; j++)
{
int a,b;
scanf("%d %d",&a,&b);
if(i >= a) continue;
v[i].pb({a,b});
}
}
memset(dp, 0, sizeof(dp));
for(auto go: v[0])
dp[go.f][min(503,go.s)]++;
for(int i = 1; i < n; i++)
{
for(int j = 1; j < m; j++)
{
dp[i][j] += dp[i][j - 1];
dp[i][j] = min(dp[i][j], MX);
}
for(auto go: v[i])
{
for(int j = 0; j + go.s < m; j++)
{
dp[go.f][j + go.s] += dp[i][j];
dp[go.f][j + go.s] = min(dp[go.f][j + go.s], MX);
}
}
}
for(int i = 0; i < m; i++)
printf("%d ",dp[n - 1][i]);
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... |