답안 #209384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209384 2020-03-14T03:48:02 Z DystoriaX Journey (NOI18_journey) C++14
69 / 100
2000 ms 16084 KB
#include <bits/stdc++.h>

using namespace std;

int n, m, h;
int dp[410][10010];
const int INF = 1e9;
const int MAX = 5 * 1e8 + 1;

int main(){
    scanf("%d%d%d", &n, &m, &h);

    for(int i = 0; i <= 10000; i++)
        for(int j = 0; j <= 400; j++)
            dp[j][i] = 0;

    dp[0][0] = 1;

    for(int i = 0; i < n - 1; i++){
        int nxt, t;
        // int idx = -1;

        // for(int j = 0; j < m; j++) dp[j + 1][i] = min(MAX, dp[j + 1][i] + dp[j][i]);

        for(int k = 0; k < h; k++){
            scanf("%d%d", &nxt, &t);

            if(nxt <= i) continue;

            for(int j = 0; j <= m; j++){
                for(int l = j + t; l <= m; l++)
                    dp[l][nxt] = min(MAX, dp[l][nxt] + dp[j][i]);
            }
        }

        // for(int j = 0; j <= m; j++)
        //     if(dp[j][i] != -1) idx = j;

        // if(idx == -1) continue;

        // for(int j = 0; j < h; j++){
        //     scanf("%d%d", &nxt, &t);

        //     if(t + idx <= m){
        //         if(dp[t + idx][nxt] == -1) dp[t + idx][nxt] = 0;

        //         dp[t + idx][nxt] = min(1LL * MAX, 1LL * dp[t + idx][nxt] + dp[idx][i]);
        //     }
        // }

        // for(int j = idx; j < m; j++){
        //     dp[j + 1][i] = min(1LL * MAX, 1LL * dp[j + 1][i] + dp[j][i]);
        // }
    }

    for(int i = 0; i < m; i++){
        if(i) printf(" ");
        printf("%d", max(dp[i][n - 1], 0));
    }

    printf("\n");
    
    return 0;
}

Compilation message

journey.cpp: In function 'int main()':
journey.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &h);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
journey.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d", &nxt, &t);
             ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15992 KB Output is correct
2 Correct 17 ms 15992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 15992 KB Output is correct
2 Correct 14 ms 15992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15992 KB Output is correct
2 Correct 17 ms 15992 KB Output is correct
3 Correct 14 ms 15992 KB Output is correct
4 Correct 14 ms 15992 KB Output is correct
5 Correct 29 ms 15996 KB Output is correct
6 Correct 25 ms 15992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15992 KB Output is correct
2 Correct 17 ms 15992 KB Output is correct
3 Correct 14 ms 15992 KB Output is correct
4 Correct 14 ms 15992 KB Output is correct
5 Correct 29 ms 15996 KB Output is correct
6 Correct 25 ms 15992 KB Output is correct
7 Correct 105 ms 15992 KB Output is correct
8 Correct 548 ms 16084 KB Output is correct
9 Correct 815 ms 15996 KB Output is correct
10 Execution timed out 2100 ms 15992 KB Time limit exceeded