Submission #425539

# Submission time Handle Problem Language Result Execution time Memory
425539 2021-06-13T06:44:17 Z chirathnirodha Jelly Flavours (IOI20_jelly) C++17
0 / 100
137 ms 152052 KB
//Coded by Chirath Nirodha
#include<bits/stdc++.h>
using namespace std;
#include "jelly.h"
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long ll;
 
bool sub4(vector<int> v){
	for(int i=1;i<v.size();i++)if(v[i]!=v[i-1])return false;
	return true;
}
bool sub5(vector<int> v,vector<int> w){
	for(int i=0;i<v.size();i++)if(v[i]!=w[i])return false;
	return true;
}
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
	int n = a.size();
	if(y==0){
		vector<vector<int>> dp1(n+1,vector<int>(x+1,0));
		for(int i=0;i<=x;i++)dp1[0][i]=0;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=x;j++){
				dp1[i][j]=dp1[i-1][j];
				if(j-a[i-1]>=0)dp1[i][j]=max(dp1[i][j],dp1[i-1][j-a[i-1]]+1);
			}
		}
		return -10;
	}
	else if(sub4(b)){
		int dp2[n+1][x+1];
		for(int i=0;i<=x;i++)dp2[0][i]=0;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=x;j++){
				dp2[i][j]=dp2[i-1][j];
				if(j-a[i-1]>=0)dp2[i][j]=max(dp2[i][j],dp2[i-1][j-a[i-1]]+1);
			}
		}
		int ans=dp2[n][x];
		ans=min(n,ans+y/b[0]);
		return ans;
	}
	else if(sub5(a,b)){
		x+=y;
		int dp3[n+1][x+1];
		for(int i=0;i<=x;i++)dp3[0][i]=0;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=x;j++){
				dp3[i][j]=dp3[i-1][j];
				if(j-a[i-1]>=0)dp3[i][j]=max(dp3[i][j],dp3[i-1][j-a[i-1]]+1);
			}
		}
		return dp3[n][x];
	}
	else{
		int dp[n+1][x+1][y+1];
		for(int i=0;i<=x;i++)for(int j=0;j<=y;j++)dp[0][x][y]=0;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=x;j++){
				for(int k=0;k<=y;k++){
					dp[i][j][k]=dp[i-1][j][k];
					if(j-a[i-1]>=0)dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-a[i-1]][k]+1);
					if(k-b[i-1]>=0)dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-b[i-1]]+1);
				}
			}
		}
		return dp[n][x][y];
	}
}

Compilation message

jelly.cpp: In function 'bool sub4(std::vector<int>)':
jelly.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=1;i<v.size();i++)if(v[i]!=v[i-1])return false;
      |              ~^~~~~~~~~
jelly.cpp: In function 'bool sub5(std::vector<int>, std::vector<int>)':
jelly.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i=0;i<v.size();i++)if(v[i]!=w[i])return false;
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 8 ms 7628 KB Output is correct
3 Correct 8 ms 7992 KB Output is correct
4 Correct 11 ms 11032 KB Output is correct
5 Correct 10 ms 8524 KB Output is correct
6 Correct 8 ms 6860 KB Output is correct
7 Correct 13 ms 9684 KB Output is correct
8 Correct 6 ms 6732 KB Output is correct
9 Correct 9 ms 8908 KB Output is correct
10 Correct 11 ms 10700 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 2 ms 1740 KB Output is correct
13 Correct 7 ms 7708 KB Output is correct
14 Correct 8 ms 7884 KB Output is correct
15 Correct 12 ms 11032 KB Output is correct
16 Correct 9 ms 8524 KB Output is correct
17 Correct 8 ms 6860 KB Output is correct
18 Correct 10 ms 9676 KB Output is correct
19 Correct 8 ms 6804 KB Output is correct
20 Correct 9 ms 8948 KB Output is correct
21 Correct 2 ms 1996 KB Output is correct
22 Correct 12 ms 10700 KB Output is correct
23 Correct 2 ms 1996 KB Output is correct
24 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '0', found: '-10'
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 8 ms 7628 KB Output is correct
3 Correct 8 ms 7992 KB Output is correct
4 Correct 11 ms 11032 KB Output is correct
5 Correct 10 ms 8524 KB Output is correct
6 Correct 8 ms 6860 KB Output is correct
7 Correct 13 ms 9684 KB Output is correct
8 Correct 6 ms 6732 KB Output is correct
9 Correct 9 ms 8908 KB Output is correct
10 Correct 11 ms 10700 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 2 ms 1740 KB Output is correct
13 Correct 7 ms 7708 KB Output is correct
14 Correct 8 ms 7884 KB Output is correct
15 Correct 12 ms 11032 KB Output is correct
16 Correct 9 ms 8524 KB Output is correct
17 Correct 8 ms 6860 KB Output is correct
18 Correct 10 ms 9676 KB Output is correct
19 Correct 8 ms 6804 KB Output is correct
20 Correct 9 ms 8948 KB Output is correct
21 Correct 2 ms 1996 KB Output is correct
22 Correct 12 ms 10700 KB Output is correct
23 Correct 2 ms 1996 KB Output is correct
24 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '0', found: '-10'
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 13380 KB 1st lines differ - on the 1st token, expected: '689', found: '-10'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 71068 KB Output is correct
2 Correct 55 ms 71364 KB Output is correct
3 Correct 59 ms 74572 KB Output is correct
4 Correct 58 ms 74700 KB Output is correct
5 Correct 59 ms 76008 KB Output is correct
6 Correct 52 ms 71500 KB Output is correct
7 Correct 67 ms 71336 KB Output is correct
8 Correct 55 ms 74724 KB Output is correct
9 Correct 58 ms 74152 KB Output is correct
10 Correct 58 ms 72000 KB Output is correct
11 Correct 5 ms 4444 KB Output is correct
12 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '0', found: '-10'
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 79300 KB Output is correct
2 Correct 106 ms 141292 KB Output is correct
3 Correct 137 ms 140240 KB Output is correct
4 Correct 114 ms 147908 KB Output is correct
5 Correct 115 ms 143688 KB Output is correct
6 Correct 113 ms 145684 KB Output is correct
7 Correct 114 ms 146924 KB Output is correct
8 Correct 121 ms 143448 KB Output is correct
9 Correct 115 ms 142244 KB Output is correct
10 Correct 120 ms 152052 KB Output is correct
11 Correct 56 ms 74328 KB Output is correct
12 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '0', found: '-10'
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 8 ms 7628 KB Output is correct
3 Correct 8 ms 7992 KB Output is correct
4 Correct 11 ms 11032 KB Output is correct
5 Correct 10 ms 8524 KB Output is correct
6 Correct 8 ms 6860 KB Output is correct
7 Correct 13 ms 9684 KB Output is correct
8 Correct 6 ms 6732 KB Output is correct
9 Correct 9 ms 8908 KB Output is correct
10 Correct 11 ms 10700 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 2 ms 1740 KB Output is correct
13 Correct 7 ms 7708 KB Output is correct
14 Correct 8 ms 7884 KB Output is correct
15 Correct 12 ms 11032 KB Output is correct
16 Correct 9 ms 8524 KB Output is correct
17 Correct 8 ms 6860 KB Output is correct
18 Correct 10 ms 9676 KB Output is correct
19 Correct 8 ms 6804 KB Output is correct
20 Correct 9 ms 8948 KB Output is correct
21 Correct 2 ms 1996 KB Output is correct
22 Correct 12 ms 10700 KB Output is correct
23 Correct 2 ms 1996 KB Output is correct
24 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '0', found: '-10'
25 Halted 0 ms 0 KB -