Submission #586478

#TimeUsernameProblemLanguageResultExecution timeMemory
586478hibikiJourney (NOI18_journey)C++11
100 / 100
61 ms22216 KiB
#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)

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);
      |             ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...