답안 #270088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
270088 2020-08-17T12:25:07 Z kaplanbar Go (COCI18_go) C++14
70 / 100
661 ms 173432 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Pk {
    ll a, b, t;
} 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;
    
    ll val = 0;

    if(T < v[cur].t) val += v[cur].b;

    ret = val;

    int d = far > cur ? -1 : 1;
    if(cur + d >= 0 && cur + d < m) {
        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[far+d].a - v[cur].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;
    }
    ll ans = 0;
    for(int i = 0; i < m; i++) {
        ans = max(ans, f(i, i, abs(v[i].a - k) ));
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 173432 KB Output is correct
2 Correct 94 ms 173304 KB Output is correct
3 Correct 102 ms 173360 KB Output is correct
4 Correct 99 ms 173304 KB Output is correct
5 Incorrect 172 ms 173432 KB Output isn't correct
6 Correct 139 ms 173308 KB Output is correct
7 Incorrect 328 ms 173432 KB Output isn't correct
8 Correct 420 ms 173432 KB Output is correct
9 Correct 392 ms 173304 KB Output is correct
10 Incorrect 661 ms 173296 KB Output isn't correct