Submission #838405

# Submission time Handle Problem Language Result Execution time Memory
838405 2023-08-26T19:35:47 Z beaboss Journey (NOI18_journey) C++14
0 / 100
2 ms 1108 KB
// Source: https://oj.uz/problem/view/NOI18_journey
// 

#include "bits/stdc++.h"

using namespace std;

#define s second
#define f first
#define pb push_back

typedef long long ll;

typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

typedef vector<ll> vi;

#define FOR(i, a, b) for (ll i = (a); i<b; i++)

const ll N = 1e4 + 10;
const ll D = 404;
vpii adj[N];
ll in[N];
ll dp[N][D];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll n, m, h;
	cin >> n >> m >> h;

	FOR(i, 0, n - 1) {
		FOR(j, 0, h) {
			ll w, c;
			cin >> c >> w;
			if (c < i) continue;
			adj[i].pb({c, w});
		}
	}

	dp[0][0]=1;


	FOR(cur, 0, n-1) {

		for (auto val: adj[cur]) {
			ll nxt, wt;
			tie(nxt, wt) = val;

			ll cur_sum = 0;
			for (ll i = 0; i + wt < m; i++) {
				cur_sum = min(cur_sum + dp[cur][i], (ll) 5e8 + 1);
				dp[nxt][i + wt] = min(dp[nxt][i + wt] + cur_sum, (ll) 5e8 + 1); 
			}

		}

	
	}

	FOR(i, 0, m) {
		if (i != 0) assert(dp[n-1][i] <= dp[n-1][i+1] && dp[n-1][i] >= 0);
		cout << min(dp[n-1][i], (ll) 5e8 + 1) << ' ';
	}
	cout << endl;
}












# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 980 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1108 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 980 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 980 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -