Submission #406479

# Submission time Handle Problem Language Result Execution time Memory
406479 2021-05-17T16:11:06 Z victoriad Jelly Flavours (IOI20_jelly) C++14
0 / 100
2000 ms 31524 KB
#include "jelly.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
#include <stack>
#include <fstream>
using namespace std;
int ma,mb;
vector<int>dp;
int maxi(int x, int y, std::vector<int> a, std::vector<int> b,int nodo,int r){
	if(dp[nodo]<r){
		dp[nodo]=r;
	if((nodo==a.size() )|| (x<ma && y<mb) ||(r==a.size())){
		return r;
	}
	else{
		if(a[nodo]<=x && b[nodo]<=y){
			return max(maxi(x-a[nodo],y,a,b,nodo+1,r+1),max(maxi(x,y-b[nodo],a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r)));
		}
		else if(a[nodo]<=x){
			return max(maxi(x-a[nodo],y,a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r));
		}
		else if(b[nodo]<=y){
			return max(maxi(x,y-b[nodo],a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r));
		}
		else{
			return maxi(x,y,a,b,nodo+1,r);
		}
	}
	}
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int n = a.size();
	ma=1e9;
	mb=1e9;
	dp.assign(n,-1);
	for(int i=0;i<n;i++){
		if(a[i]<ma)ma=a[i];
		if(b[i]<mb)mb=b[i];
	}
	return maxi(x,y,a,b,0,0);
}

Compilation message

jelly.cpp: In function 'int maxi(int, int, std::vector<int>, std::vector<int>, int, int)':
jelly.cpp:19:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  if((nodo==a.size() )|| (x<ma && y<mb) ||(r==a.size())){
      |      ~~~~^~~~~~~~~~
jelly.cpp:19:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  if((nodo==a.size() )|| (x<ma && y<mb) ||(r==a.size())){
      |                                           ~^~~~~~~~~~
jelly.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 31096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 30648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 31524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -