Submission #86844

#TimeUsernameProblemLanguageResultExecution timeMemory
86844jovitreGo (COCI18_go)C++14
30 / 100
11 ms9024 KiB
#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 (stderr)

go.cpp: In function 'int main()':
go.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &k, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
go.cpp:36:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= m; i++) scanf("%d%d%d", casa + i, peso + i, t + i);
                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...