답안 #658802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658802 2022-11-15T01:47:34 Z pere_gil 메기 농장 (IOI22_fish) C++17
0 / 100
1000 ms 1941728 KB
#include "fish.h"
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){
	int h=0;
	for(int i=0;i<m;i++) h=max(h,y[i]+2);
	
	ll fish[n][h]; memset(fish,0,sizeof fish);
	for(int i=0;i<m;i++) fish[x[i]][y[i]+1]=w[i];
	for(int i=0;i<n;i++)
		for(int j=1;j<h;j++) fish[i][j]+=fish[i][j-1];

	ll dp[n][h][h][h]; memset(dp,0,sizeof dp);
	ll best[n]; memset(best,0,sizeof best);
	for(int i=0;i<h;i++)
		for(int j=0;j<h;j++)
			for(int k=0;k<h;k++){
				if(j>k)
					dp[1][i][j][k]=fish[1][j]-fish[1][k];
				else
					dp[1][i][j][k]=fish[0][k]-fish[0][j];
				best[1]=max(best[1],dp[1][i][j][k]);
			}

	for(int i=2;i<n;i++){
		for(int j=0;j<h;j++){
			for(int k=0;k<h;k++){
				for(int l=0;l<h;l++){
					if(i>=3) dp[i][j][k][l]+=best[i-3];

					if(j>k){
						if(k>l) dp[i][j][k][l]+=fish[i-1][j]-fish[i-1][k]+fish[i][k]-fish[i][l];
						else dp[i][j][k][l]+=fish[i-1][max(j,l)]-fish[i-1][k];
					}
					else{
						if(k>l) dp[i][j][k][l]+=fish[i-2][k]-fish[i-2][j]+fish[i][k]-fish[i][l];
						else dp[i][j][k][l]+=fish[i-2][k]-fish[i-2][j]+fish[i-1][l]-fish[i-1][k];
					}
					best[i]=max(best[i],dp[i][j][k][l]);
				}
			}
		}
	}

	ll res=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<h;j++)
			for(int k=0;k<j;k++)
				res=max(res,dp[n-1][i][j][k]);
	
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1139 ms 1941728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 8912 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 8912 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1139 ms 1941728 KB Time limit exceeded
2 Halted 0 ms 0 KB -