# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
410732 |
2021-05-23T14:21:34 Z |
snasibov05 |
Go (COCI18_go) |
C++14 |
|
362 ms |
237512 KB |
#include <iostream>
#include <vector>
using namespace std;
struct data{
int x;
int c;
int t;
};
const int tmax = 2005;
int calc(int l, int r, int t, int lst, int n,vector<data>& v, vector<vector<vector<vector<int>>>>& dp){
if (t >= tmax || l < 0 || r >= n) return 0;
if (dp[lst][l][r][t] != -1) return dp[lst][l][r][t];
int res = 0;
if (lst == 0){
res = max(res, calc(l-1, r, t + (v[l].x - v[l-1].x), 0, n, v, dp));
res = max(res, calc(l, r+1, t + (v[r+1].x - v[l].x), 1, n, v, dp));
if (t < v[l].t) res += v[l].c;
} else{
res = max(res, calc(l-1, r, t + (v[r].x - v[l-1].x), 0, n, v, dp));
res = max(res, calc(l, r+1, t + (v[r+1].x - v[r].x), 1, n, v, dp));
if (t < v[r].t) res += v[r].c;
}
return dp[lst][l][r][t] = res;
}
int main() {
int n, k, m; cin >> n >> k >> m;
vector<data> v(n);
for (int i = 0; i < m; ++i) {
cin >> v[i].x >> v[i].c >> v[i].t;
}
vector<vector<vector<vector<int>>>> dp(2, vector<vector<vector<int>>>(m, vector<vector<int>>(m, vector<int>(tmax, -1))));
int ans = 0;
for (int i = 0; i < m; ++i){
ans = max(ans, calc(i, i, abs(k - v[i].x), 0, m, v, dp));
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
2 ms |
2756 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
8 ms |
9804 KB |
Output is correct |
5 |
Correct |
81 ms |
59788 KB |
Output is correct |
6 |
Correct |
96 ms |
85892 KB |
Output is correct |
7 |
Correct |
182 ms |
116724 KB |
Output is correct |
8 |
Correct |
225 ms |
152224 KB |
Output is correct |
9 |
Correct |
289 ms |
192596 KB |
Output is correct |
10 |
Correct |
362 ms |
237512 KB |
Output is correct |