답안 #591915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591915 2022-07-08T08:40:47 Z l_reho 말 (IOI15_horses) C++14
17 / 100
215 ms 524288 KB
#include "horses.h"
#include <stdio.h>
#include <stdlib.h>

static char _buffer[1024];
static int _currentChar = 0;
static int _charsNumber = 0;
static FILE *_inputFile, *_outputFile;

#include <bits/stdc++.h>
using namespace std;

vector<vector<long long>> dp;

int init(int N, int X[], int Y[]) {
	
	dp.assign(N, vector<long long>(1000, 0));
	
	vector<long long> pref(N+1, 0);
	
	pref[0] = 1;
	
	for(int i = 1; i <= N; i++)
		pref[i] = pref[i-1] * X[i-1];
		
	for(int i = 0; i <= pref[1]; i++)
		dp[0][i] = Y[0] * (pref[1]-i);
	
	for(int i = 1; i < N; i++){
		for(int h = 0; h <= pref[i]; h++){
			for(int k = 0; k <= X[i]*h; k++){
				dp[i][X[i]*h-k] = max(dp[i][X[i]*h-k], dp[i-1][h] + k*Y[i]);
			}
		}
		
	}
	
	long long ans = 0;
	for(int i = 0; i <= pref[N]; i++){
		ans = max(ans, dp[N-1][i]);
	}
	
	
	
	return ans;
}

int updateX(int pos, int val) {	
	return 0;
}

int updateY(int pos, int val) {
	return 0;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:48:17: warning: unused parameter 'pos' [-Wunused-parameter]
   48 | int updateX(int pos, int val) {
      |             ~~~~^~~
horses.cpp:48:26: warning: unused parameter 'val' [-Wunused-parameter]
   48 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:52:17: warning: unused parameter 'pos' [-Wunused-parameter]
   52 | int updateY(int pos, int val) {
      |             ~~~~^~~
horses.cpp:52:26: warning: unused parameter 'val' [-Wunused-parameter]
   52 | int updateY(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: At global scope:
horses.cpp:8:27: warning: '_outputFile' defined but not used [-Wunused-variable]
    8 | static FILE *_inputFile, *_outputFile;
      |                           ^~~~~~~~~~~
horses.cpp:8:14: warning: '_inputFile' defined but not used [-Wunused-variable]
    8 | static FILE *_inputFile, *_outputFile;
      |              ^~~~~~~~~~
horses.cpp:7:12: warning: '_charsNumber' defined but not used [-Wunused-variable]
    7 | static int _charsNumber = 0;
      |            ^~~~~~~~~~~~
horses.cpp:6:12: warning: '_currentChar' defined but not used [-Wunused-variable]
    6 | static int _currentChar = 0;
      |            ^~~~~~~~~~~~
horses.cpp:5:13: warning: '_buffer' defined but not used [-Wunused-variable]
    5 | static char _buffer[1024];
      |             ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 0 ms 304 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 5 ms 388 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 304 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Runtime error 31 ms 712 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 215 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 300 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Runtime error 32 ms 716 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 300 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 300 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Runtime error 32 ms 676 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -