Submission #372037

#TimeUsernameProblemLanguageResultExecution timeMemory
372037shrek12357Journey (NOI18_journey)C++14
100 / 100
205 ms35436 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include <stack> #include <iomanip> #include <assert.h> #include <bitset> //#include "cycle.h" using namespace std; #define ll long long //cin.tie(0);ios_base::sync_with_stdio(0); const int MAXN = 1e4+5; const int MAXM = 405; const int MAXH = 105; ll dp[MAXN][MAXM]; int main() { int n, m, h; cin >> n >> m >> h; vector<pair<int, int>> adjList[MAXN]; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < h; j++) { int a, b; cin >> a >> b; if (a <= i) { continue; } adjList[i].push_back({ a, b }); } } dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if(i != 0) dp[i][j + 1] = min(dp[i][j + 1] + dp[i][j], (ll)500000001); for (auto k : adjList[i]) { if (j + k.second < m) { dp[k.first][j + k.second] = min(dp[k.first][j + k.second] + dp[i][j], (ll)500000001); } } } } for (int i = 0; i < m; i++) { cout << dp[n - 1][i] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...