# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147293 | JovanK26 | Lightning Rod (NOI18_lightningrod) | C++14 | 85 ms | 55112 KiB |
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 <bits/stdc++.h>
using namespace std;
int n,m,h;
long long f[10001][401];
vector <pair<int,int> >v[10001];
void solve()
{
for(int start=0;start<n-1;start++)
{
for(int i=0;i<v[start].size();i++)
{
if(v[start][i].first>start)
{
long long sum=0;
for(int j=0;j<m-v[start][i].second;j++)
{
sum=min(sum+f[start][j],(long long)500000001);
f[v[start][i].first][j+v[start][i].second]=min(f[v[start][i].first][j+v[start][i].second]+sum,(long long)500000001);
}
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> h;
int j,k;
for(int i=0;i<n-1;i++)
{
for(int t=0;t<h;t++)
{
cin >> j >> k;
v[i].push_back(make_pair(j,k));
v[j].push_back(make_pair(i,k));
}
}
f[0][0]=1;
solve();
for(int i=0;i<m;i++)
{
cout << min((long long)500000001,f[n-1][i])<<' ';
}
return 0;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |