Submission #586420

#TimeUsernameProblemLanguageResultExecution timeMemory
586420krit3379Journey (NOI18_journey)C++17
100 / 100
146 ms6456 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 10005 int dp[405][N]; vector<pair<int,int>> g[N]; int main(){ int n,m,h,i,j,a,w; scanf("%d %d %d",&n,&m,&h); for(i=0;i<n-1;i++){ for(j=0;j<h;j++){ scanf("%d %d",&a,&w); if(a<=i)continue; g[i].push_back({a,w}); } } dp[0][0]=1; for(j=0;j<m;j++){ for(i=0;i<n-1;i++){ dp[j+1][i]=min(dp[j+1][i]+dp[j][i],500000001); for(auto [x,w]:g[i])if(j+w<m)dp[j+w][x]=min(dp[j+w][x]+dp[j][i],500000001); } } for(i=0;i<m;i++)printf("%d ",dp[i][n-1]); return 0; }

Compilation message (stderr)

journey.cpp: In function 'int main()':
journey.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d %d",&n,&m,&h);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
journey.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d %d",&a,&w);
      |             ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...