# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
239745 |
2020-06-17T08:37:09 Z |
VEGAnn |
Go (COCI18_go) |
C++14 |
|
49 ms |
47872 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], 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++)
f[tim][l][r] = -1;
for (int i = 0; i < m; i++)
if (a[i][0] == k && a[i][1] == 0)
f[1][i][i] = 0;
for (int tim = 1; tim < T; tim++){
for (int l = 0; l < m; l++)
for (int r = l; r < m; r++){
if (f[tim][l][r] < 0) continue;
ans = max(ans, f[tim][l][r]);
if (l > 0){
int nw = tim + a[l][0] - a[l - 1][0];
if (nw < T)
upd(f[nw][l - 1][r], f[tim][l][r] + (nw <= a[l - 1][2] ? a[l - 1][1] : 0));
}
if (r < m - 1){
int nw = tim + a[r + 1][0] - a[r][0];
if (nw < T)
upd(f[nw][l][r + 1], f[tim][l][r] + (nw <= a[r + 1][2] ? a[r + 1][1] : 0));
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
10240 KB |
Output is correct |
2 |
Correct |
11 ms |
12800 KB |
Output is correct |
3 |
Correct |
13 ms |
14592 KB |
Output is correct |
4 |
Correct |
17 ms |
17152 KB |
Output is correct |
5 |
Incorrect |
25 ms |
30208 KB |
Output isn't correct |
6 |
Correct |
30 ms |
34560 KB |
Output is correct |
7 |
Correct |
34 ms |
38912 KB |
Output is correct |
8 |
Incorrect |
40 ms |
43384 KB |
Output isn't correct |
9 |
Incorrect |
45 ms |
47608 KB |
Output isn't correct |
10 |
Incorrect |
49 ms |
47872 KB |
Output isn't correct |