This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <map>
#define int long long
#define pb push_back
#define ll long long
#define MOD 1000000007
#define mid(l, u) (l+u)/2
#define rchild(i) (i*2)
#define lchild(i) (i*2 + 1)
using namespace std;
int n, m, h;
vector<pair<int, int>> mat[10000];
int dp[10000][405];
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>h;
for(int i =0 ;i<(n-1);i++){
for(int j =0;j<h;j++){
int num, time;
cin>>num>>time;
if(num<=i) continue;
mat[i].push_back(make_pair(num, time));
}
}
for(pair<int, int> i: mat[0]){
dp[i.first][i.second]++;
}
for(int i = 1;i<n;i++){
for(int j = 0;j<m;j++){
if(j){
dp[i][j]+=dp[i][j-1];
}
dp[i][j] = min(dp[i][j], (int) 500000001);
for(pair<int, int> k: mat[i]){
if(j+k.second>=m) continue;
dp[k.first][j+k.second]+=dp[i][j];
dp[k.first][j+k.second] = min(dp[k.first][j+k.second], (int) 500000001);
}
}
}
for(int i = 0;i<m;i++){
cout<<dp[n-1][i]<<" ";
}
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |