Submission #682878

# Submission time Handle Problem Language Result Execution time Memory
682878 2023-01-17T06:57:44 Z irmuun Catfish Farm (IOI22_fish) C++17
18 / 100
83 ms 7452 KB
#include<bits/stdc++.h>
#include "fish.h"
using namespace std;
#define ll long long
long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
	int count=0,X=-1,Y=-1;
	for(int i=0;i<m;i++){
		if(x[i]%2==0){
			count++;
		}
		X=max(X,x[i]);
		Y=max(Y,y[i]);
	}
	if(count==m){//subtask1
		ll ans=0;
		for(int i=0;i<m;i++){
			ans+=w[i];
		}
		return ans;
	}
	if(X<=1){//subtask2
		ll res=0;
		int dp[n+5][2];
		for(int i=0;i<=n;i++){
			dp[i][0]=0;
			dp[i][1]=0;
		}
		ll ans;
		for(int i=0;i<m;i++){
			if(x[i]==1){
				res+=w[i];
			}
			dp[y[i]+1][x[i]]=w[i];
		}
		if(n==2){
			return max(dp[1][0]+dp[2][0],dp[1][1]+dp[2][1]);
		}
		ans=res;
		for(int i=1;i<=n;i++){
			res+=dp[i][0]-dp[i][1];
			ans=max(ans,res);
		}
		return ans;
	}
	if(Y==0){
		int arr[n+5];
		fill(arr,arr+n+3,0);
		for(int i=0;i<m;i++){
			arr[x[i]+1]=w[i];
		}
		ll dp[n+5][2][2];//current pos, current state,current-1 state
		dp[2][0][0]=0;
		dp[2][1][0]=arr[1];
		dp[2][0][1]=arr[2];
		dp[2][1][1]=0;
		for(int i=3;i<=n;i++){
			dp[i][1][1]=max(dp[i-1][1][0],dp[i-1][1][1]);
			dp[i][1][0]=max(dp[i-1][0][1],dp[i-1][0][0]+arr[i-1]);
			dp[i][0][1]=max(dp[i-1][1][0],dp[i-1][1][1])+arr[i];
			dp[i][0][0]=max(dp[i-1][0][1],dp[i-1][0][0]);
		}
		return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[n][1][1]});
	}
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2124 KB Output is correct
2 Correct 27 ms 2636 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 83 ms 7272 KB Output is correct
6 Correct 76 ms 7264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 43 ms 4772 KB Output is correct
3 Correct 57 ms 5720 KB Output is correct
4 Correct 22 ms 2152 KB Output is correct
5 Correct 33 ms 2644 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 22 ms 2900 KB Output is correct
13 Correct 26 ms 3384 KB Output is correct
14 Correct 22 ms 2940 KB Output is correct
15 Correct 37 ms 3148 KB Output is correct
16 Correct 25 ms 2804 KB Output is correct
17 Correct 25 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 3 ms 3772 KB Output is correct
3 Correct 16 ms 4656 KB Output is correct
4 Correct 11 ms 4576 KB Output is correct
5 Correct 28 ms 6088 KB Output is correct
6 Correct 23 ms 7084 KB Output is correct
7 Correct 27 ms 7440 KB Output is correct
8 Correct 27 ms 7392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 3 ms 3772 KB Output is correct
3 Correct 16 ms 4656 KB Output is correct
4 Correct 11 ms 4576 KB Output is correct
5 Correct 28 ms 6088 KB Output is correct
6 Correct 23 ms 7084 KB Output is correct
7 Correct 27 ms 7440 KB Output is correct
8 Correct 27 ms 7392 KB Output is correct
9 Incorrect 26 ms 7452 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2124 KB Output is correct
2 Correct 27 ms 2636 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 83 ms 7272 KB Output is correct
6 Correct 76 ms 7264 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 43 ms 4772 KB Output is correct
9 Correct 57 ms 5720 KB Output is correct
10 Correct 22 ms 2152 KB Output is correct
11 Correct 33 ms 2644 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 22 ms 2900 KB Output is correct
19 Correct 26 ms 3384 KB Output is correct
20 Correct 22 ms 2940 KB Output is correct
21 Correct 37 ms 3148 KB Output is correct
22 Correct 25 ms 2804 KB Output is correct
23 Correct 25 ms 3152 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 3 ms 3772 KB Output is correct
26 Correct 16 ms 4656 KB Output is correct
27 Correct 11 ms 4576 KB Output is correct
28 Correct 28 ms 6088 KB Output is correct
29 Correct 23 ms 7084 KB Output is correct
30 Correct 27 ms 7440 KB Output is correct
31 Correct 27 ms 7392 KB Output is correct
32 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
33 Halted 0 ms 0 KB -