# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
239749 |
2020-06-17T08:46:08 Z |
VEGAnn |
Go (COCI18_go) |
C++14 |
|
188 ms |
95480 KB |
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define i3 array<int,3>
using namespace std;
typedef long double ld;
typedef long long ll;
const int N = 200100;
const int M = 110;
const int K = 110;
const int T = 2010;
const int oo = 2e9;
i3 a[M];
short f[T][M][M][2], ans = 0, n, k, m;
void upd(short &x, short y){
x = max(x, y);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> k >> m;
for (int i = 0; i < m; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
a[m++] = {k, 0, 1};
sort(a, a + m);
for (int tim = 1; tim < T; tim++)
for (int l = 0; l < m; l++)
for (int r = l; r < m; r++)
for (int tp = 0; tp < 2; tp++)
f[tim][l][r][tp] = -1;
for (int i = 0; i < m; i++)
if (a[i][0] == k && a[i][1] == 0)
f[1][i][i][0] = 0;
for (int tim = 1; tim < T; tim++){
for (int l = 0; l < m; l++)
for (int r = l; r < m; r++)
for (int tp = 0; tp < 2; tp++){
if (f[tim][l][r][tp] < 0) continue;
if (ans < f[tim][l][r][tp]){
ans = f[tim][l][r][tp];
// cerr << ans << " " << tim << " " << l << " " << r << '\n';
}
if (l > 0){
int nw = tim;
if (tp == 0)
nw += a[l][0] - a[l - 1][0];
else nw += a[r][0] - a[l - 1][0];
if (nw < T)
upd(f[nw][l - 1][r][0], f[tim][l][r][tp] + (nw <= a[l - 1][2] ? a[l - 1][1] : 0));
}
if (r < m - 1){
int nw = tim;
if (tp == 1)
nw += a[r + 1][0] - a[r][0];
else nw += a[r + 1][0] - a[l][0];
if (nw < T)
upd(f[nw][l][r + 1][1], f[tim][l][r][tp] + (nw <= a[r + 1][2] ? a[r + 1][1] : 0));
}
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
12032 KB |
Output is correct |
2 |
Correct |
14 ms |
17280 KB |
Output is correct |
3 |
Correct |
16 ms |
20736 KB |
Output is correct |
4 |
Correct |
20 ms |
25984 KB |
Output is correct |
5 |
Correct |
57 ms |
52096 KB |
Output is correct |
6 |
Correct |
59 ms |
60920 KB |
Output is correct |
7 |
Correct |
88 ms |
69496 KB |
Output is correct |
8 |
Correct |
103 ms |
78200 KB |
Output is correct |
9 |
Correct |
188 ms |
86904 KB |
Output is correct |
10 |
Correct |
125 ms |
95480 KB |
Output is correct |