답안 #169211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169211 2019-12-19T05:10:57 Z aggu_01000101 Journey (NOI18_journey) C++14
100 / 100
173 ms 36884 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <map>
#define int long long
#define pb push_back
#define ll long long
#define MOD 1000000007
#define mid(l, u) (l+u)/2
#define rchild(i) (i*2)
#define lchild(i) (i*2 + 1)
using namespace std;
int n, m, h;
vector<pair<int, int>> mat[10000];
int dp[10000][405];
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>h;
    for(int i =0 ;i<(n-1);i++){
        for(int j =0;j<h;j++){
            int num, time;
            cin>>num>>time;
            if(num<=i) continue;
            mat[i].push_back(make_pair(num, time));
        }
    }
        for(pair<int, int> i: mat[0]){
            dp[i.first][i.second]++;
        }
    for(int i = 1;i<n;i++){
        for(int j = 0;j<m;j++){
            if(j){
                dp[i][j]+=dp[i][j-1];
            }
            dp[i][j] = min(dp[i][j], (int) 500000001);
            for(pair<int, int> k: mat[i]){
                if(j+k.second>=m) continue;
                dp[k.first][j+k.second]+=dp[i][j];
                dp[k.first][j+k.second] = min(dp[k.first][j+k.second], (int) 500000001);
            }
        }
    }
    for(int i = 0;i<m;i++){
        cout<<dp[n-1][i]<<" ";
    }
    cout<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 4 ms 888 KB Output is correct
6 Correct 4 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 4 ms 888 KB Output is correct
6 Correct 4 ms 1016 KB Output is correct
7 Correct 107 ms 36884 KB Output is correct
8 Correct 107 ms 22564 KB Output is correct
9 Correct 29 ms 3448 KB Output is correct
10 Correct 173 ms 5320 KB Output is correct