Submission #156369

# Submission time Handle Problem Language Result Execution time Memory
156369 2019-10-05T11:27:17 Z brcode Journey (NOI18_journey) C++14
100 / 100
245 ms 43172 KB
#include <iostream>
#include <vector>

using namespace std;
const int MAXN = 10010;
long long dp[MAXN][500];
vector<pair<int,int>> v1[MAXN];

int main(){
    int n,m,h;
    cin>>n>>m>>h;
    for(int i=1;i<n;i++){
        for(int j=1;j<=h;j++){
            int x,y;
            cin>>x>>y;
            if(x+1<=i){
                continue;
            }
            v1[x+1].push_back(make_pair(i,y));
            if(i==1){
                dp[x+1][y]++;
            }
        }
    }
    for(int i=2;i<=n;i++){
        for(int k=0;k<=m;k++){
            if(k){
                dp[i][k] += dp[i][k-1];
            }
            for(auto x:v1[i]){
               if(k-x.second>=0 && x.first!=1){
                    dp[i][k]+=dp[x.first][k-x.second];
                    dp[i][k] = min(dp[i][k],(long long)500000001);
               }
            }
        }
    }
    for(int i=0;i<m;i++){
        cout<<dp[n][i]<<" ";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 245 ms 43172 KB Output is correct
8 Correct 197 ms 26360 KB Output is correct
9 Correct 42 ms 3960 KB Output is correct
10 Correct 232 ms 5468 KB Output is correct