Submission #141113

#TimeUsernameProblemLanguageResultExecution timeMemory
141113tincamateiJourney (NOI18_journey)C++14
100 / 100
145 ms11128 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 10000; const int MAX_M = 400; const int INF = 500000001; vector<pair<int, int> > graph[MAX_N]; int dp[MAX_M][MAX_N]; int sp[MAX_M][MAX_N]; int main() { int n, m, h; scanf("%d%d%d", &n, &m, &h); for(int i = 0; i < n - 1; ++i) { for(int j = 0; j < h; ++j) { int to, sl; scanf("%d%d", &to, &sl); if(i < to) graph[to].push_back({i, sl}); } } for(int i = 0; i < m; ++i) sp[i][0] = 1; dp[0][0] = 1; for(int i = 0; i < m; ++i) for(int j = 1; j < n; ++j) { for(auto it: graph[j]) if(it.second <= i) dp[i][j] = min(INF, dp[i][j] + sp[i - it.second][it.first]); if(i > 0) sp[i][j] = sp[i - 1][j]; sp[i][j] = min(INF, sp[i][j] + dp[i][j]); } for(int i = 0; i < m; ++i) printf("%d ", dp[i][n - 1]); return 0; }

Compilation message (stderr)

journey.cpp: In function 'int main()':
journey.cpp:16:7: 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:22:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d", &to, &sl);
    ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...