# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
270056 |
2020-08-17T12:14:48 Z |
kaplanbar |
Go (COCI18_go) |
C++14 |
|
377 ms |
173532 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Pk {
ll a, b, t;
bool operator<(const Pk other) const {
return a < other.a;
}
} v[105];
int n, m, k;
ll dp[105][105][2005];
ll f(int cur, int far, int T) {
ll &ret = dp[cur][far][T];
if(~ret) return ret;
ret = 0;
ll val = 0;
if(T < v[cur].t) val += v[cur].b;
int d = far > cur ? -1 : 1;
if(cur + d >= 0 && cur + d < m) {
if(cur == 2 && far == 2) {
cout << T + abs(v[cur + d].a - v[cur].a) << endl;
}
ret = max(ret, val + f(cur + d, far, T + abs(v[cur + d].a - v[cur].a)));
}
d *= -1;
if(far + d >= 0 && far + d < m) {
ret = max(ret, val + f(far + d, cur, T + abs(v[cur].a - v[far].a) + abs(v[far + d].a - v[far].a) ));
}
return ret;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
memset(dp, -1, sizeof dp);
cin >> n >> k >> m;
for(int i = 0; i < m; i++) {
cin >> v[i].a >> v[i].b >> v[i].t;
}
v[m++] = {k, 0, 0};
sort(v, v + m);
for(int i = 0; i < m; i++) {
if(v[i].a == k) {
cout << f(i,i,0);
exit(0);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
173304 KB |
Output isn't correct |
2 |
Correct |
106 ms |
173432 KB |
Output is correct |
3 |
Correct |
108 ms |
173432 KB |
Output is correct |
4 |
Incorrect |
98 ms |
173400 KB |
Output isn't correct |
5 |
Incorrect |
164 ms |
173416 KB |
Output isn't correct |
6 |
Correct |
123 ms |
173304 KB |
Output is correct |
7 |
Correct |
337 ms |
173304 KB |
Output is correct |
8 |
Incorrect |
377 ms |
173436 KB |
Output isn't correct |
9 |
Correct |
334 ms |
173304 KB |
Output is correct |
10 |
Correct |
310 ms |
173532 KB |
Output is correct |