답안 #586478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586478 2022-06-30T10:16:03 Z hibiki Journey (NOI18_journey) C++11
100 / 100
61 ms 22216 KB
#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

journey.cpp: In function 'int main()':
journey.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d %d",&n,&m,&h);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
journey.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |             scanf("%d %d",&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 20308 KB Output is correct
2 Correct 8 ms 20276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 20260 KB Output is correct
2 Correct 8 ms 20252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 20308 KB Output is correct
2 Correct 8 ms 20276 KB Output is correct
3 Correct 10 ms 20260 KB Output is correct
4 Correct 8 ms 20252 KB Output is correct
5 Correct 9 ms 20308 KB Output is correct
6 Correct 9 ms 20264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 20308 KB Output is correct
2 Correct 8 ms 20276 KB Output is correct
3 Correct 10 ms 20260 KB Output is correct
4 Correct 8 ms 20252 KB Output is correct
5 Correct 9 ms 20308 KB Output is correct
6 Correct 9 ms 20264 KB Output is correct
7 Correct 61 ms 22216 KB Output is correct
8 Correct 58 ms 21724 KB Output is correct
9 Correct 19 ms 20564 KB Output is correct
10 Correct 53 ms 21548 KB Output is correct