답안 #658803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658803 2022-11-15T02:12:47 Z pere_gil 메기 농장 (IOI22_fish) C++17
0 / 100
790 ms 2097152 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<h;k++)
				res=max(res,dp[n-1][i][j][k]);
    	
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 789 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 790 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8788 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: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8788 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 789 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -