# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86844 | 2018-11-27T18:58:17 Z | jovitre | Go (COCI18_go) | C++14 | 11 ms | 9024 KB |
#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; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 8696 KB | Output isn't correct |
2 | Incorrect | 11 ms | 8820 KB | Output isn't correct |
3 | Correct | 9 ms | 8896 KB | Output is correct |
4 | Correct | 9 ms | 8896 KB | Output is correct |
5 | Incorrect | 9 ms | 8948 KB | Output isn't correct |
6 | Incorrect | 9 ms | 8948 KB | Output isn't correct |
7 | Incorrect | 9 ms | 8948 KB | Output isn't correct |
8 | Correct | 9 ms | 9024 KB | Output is correct |
9 | Incorrect | 9 ms | 9024 KB | Output isn't correct |
10 | Incorrect | 11 ms | 9024 KB | Output isn't correct |