# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94869 |
2019-01-24T16:54:38 Z |
karma |
Journey (NOI18_journey) |
C++11 |
|
168 ms |
20888 KB |
#include<bits/stdc++.h>
#define For(i, a, b) for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName "test"
#define ll long long
#define ld long double
#define ull unsigned long long
#define Print(x) cerr << #x << "is " << x << '\n';
#define pb push_back
#define X first
#define Y second
//#define Karma
using namespace std;
template<typename T> inline void Cin(T &x)
{
char c;
T sign = 1;
x = 0;
for (c = getchar(); c < '0' || c > '9'; c = getchar())
if (c == '-') sign = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e4 + 7;
const int M = 407;
const int inf = int(5e8) + 1;
int n, m, h, v, k, f[N][M];
vector<pii> a[N];
void Enter()
{
Cin(n, m, h);
for(int i = 0, lim = n - 1; i < lim; ++i) {
for(int j = 0; j < h; ++j) {
Cin(v, k);
a[i].emplace_back(v, k);
}
}
f[0][0] = 1;
for(int i = 0; i < m; ++i) {
for(int j = 0, lim = n - 1; j < lim; ++j) {
if(i) f[j][i] = min(inf, f[j][i] + f[j][i - 1]);
for(pii p: a[j]) {
int NextDay = p.Y + i, NextCity = p.X;
if(NextDay < m && NextCity > j && f[NextCity][NextDay] < inf) f[NextCity][NextDay] = min(inf, f[NextCity][NextDay] + f[j][i]);
}
}
cout << f[n - 1][i] << ' ';
}
}
void Solve()
{
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef Karma
freopen(FileName".inp", "r", stdin);
freopen(FileName".out", "w", stdout);
#endif // Karma
Enter();
Solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
628 KB |
Output is correct |
3 |
Correct |
2 ms |
632 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
628 KB |
Output is correct |
3 |
Correct |
2 ms |
632 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
69 ms |
20888 KB |
Output is correct |
8 |
Correct |
168 ms |
13048 KB |
Output is correct |
9 |
Correct |
55 ms |
2248 KB |
Output is correct |
10 |
Correct |
116 ms |
3192 KB |
Output is correct |