답안 #406480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406480 2021-05-17T16:12:10 Z victoriad Jelly Flavours (IOI20_jelly) C++14
0 / 100
2000 ms 36184 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);
		}
	}

	}
	else return -1e9;
}
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())){
      |                                           ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2098 ms 36184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 317 ms 30776 KB 1st lines differ - on the 1st token, expected: '62', found: '26'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 670 ms 31984 KB 1st lines differ - on the 1st token, expected: '154', found: '41'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -