Submission #86842

# Submission time Handle Problem Language Result Execution time Memory
86842 2018-11-27T18:50:08 Z jovitre Go (COCI18_go) C++14
30 / 100
42 ms 43764 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][MAXN * 10];
int casa[MAXN];
int peso[MAXN];
int t[MAXN];

int calc(int idx, int casaAtual, int tempo){
	if(idx > m) return 0;

	if(dp[idx][tempo] != -1) return dp[idx][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[idx][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

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 time Memory Grader output
1 Incorrect 42 ms 43512 KB Output isn't correct
2 Incorrect 42 ms 43600 KB Output isn't correct
3 Correct 40 ms 43600 KB Output is correct
4 Correct 37 ms 43672 KB Output is correct
5 Incorrect 38 ms 43744 KB Output isn't correct
6 Incorrect 36 ms 43764 KB Output isn't correct
7 Incorrect 36 ms 43764 KB Output isn't correct
8 Correct 36 ms 43764 KB Output is correct
9 Incorrect 36 ms 43764 KB Output isn't correct
10 Incorrect 36 ms 43764 KB Output isn't correct