# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
86844 | jovitre | Go (COCI18_go) | C++14 | 11 ms | 9024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1050
#define MAXSZ 2050
#define INF 999999999
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <ll> vi;
int n, k, m;
int dp[MAXN][MAXSZ];
int casa[MAXN];
int peso[MAXN];
int t[MAXN];
int calc(int idx, int casaAtual, int tempo){
if(idx > m) return 0;
if(dp[casaAtual][tempo] != -1) return dp[casaAtual][tempo];
int opt1 = calc(idx + 1, casaAtual, tempo);
int opt2 = 0;
if(tempo + abs(casaAtual - casa[idx]) < t[idx]) opt2 = peso[idx] + calc(idx + 1, casa[idx], tempo + abs(casaAtual - casa[idx]));
return dp[casaAtual][tempo] = max(opt1, opt2);
}
int main(){
scanf("%d%d%d", &n, &k, &m);
for(int i = 1; i <= m; i++) scanf("%d%d%d", casa + i, peso + i, t + i);
memset(dp, -1, sizeof(dp));
int res = calc(1, k, 0);
printf("%d\n", res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |