답안 #431340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431340 2021-06-17T11:06:29 Z charterla Jelly Flavours (IOI20_jelly) C++14
0 / 100
73 ms 488 KB
#include "jelly.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> A,B;
int tag[2005];
bool cmp(int a,int b){
	return A[a]<A[b];
}

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
	A=a;B=b;
	for(int i=0;i<A.size();i++)tag[i]=i;
	sort(tag,tag+A.size(),cmp);
	//for(int i=0;i<A.size();i++)cout<<i<<":<"<<tag[i]<<">->"<<A[tag[i]]<<" ";cout<<endl;
	
	int f[10005][2],ans=0;
	for(int j=0;j<=y;j++){f[j][0]=0;f[j][1]=x;}
	
	for(int k=0;k<a.size();k++){
		for(int j=y;j>=0;j--){
			if(f[j][1]>=a[tag[k]] && (j<b[tag[k]] || (f[j][0]+1>f[j-b[tag[k]]][0]+1))){
				f[j][0]=max(f[j][0],f[j][0]+1);
				f[j][1]-=a[tag[k]];
			}
			if(j>=b[tag[k]] && (f[j][1]<a[tag[k]] || (f[j-b[tag[k]]][0]+1>f[j][0]+1))){
				f[j][0]=max(f[j][0],f[j-b[tag[k]]][0]+1);
				f[j][1]=f[j-b[tag[k]]][1];
			}
			
			ans=max(ans,f[j][0]);
		}
		//cout<<a[tag[k]]<<","<<b[tag[k]]<<": ";for(int j=0;j<=y;j++)cout<<f[j][0]<<","<<f[j][1]<<" ";cout<<endl;
	}
	
	return ans;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<A.size();i++)tag[i]=i;
      |              ~^~~~~~~~~
jelly.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int k=0;k<a.size();k++){
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB 1st lines differ - on the 1st token, expected: '689', found: '671'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 35 ms 416 KB Output is correct
3 Correct 46 ms 488 KB Output is correct
4 Correct 66 ms 332 KB Output is correct
5 Correct 55 ms 412 KB Output is correct
6 Correct 53 ms 332 KB Output is correct
7 Correct 47 ms 332 KB Output is correct
8 Correct 39 ms 332 KB Output is correct
9 Correct 53 ms 332 KB Output is correct
10 Correct 55 ms 412 KB Output is correct
11 Correct 39 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 38 ms 424 KB Output is correct
14 Correct 53 ms 332 KB Output is correct
15 Incorrect 73 ms 408 KB 1st lines differ - on the 1st token, expected: '1222', found: '1949'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 332 KB 1st lines differ - on the 1st token, expected: '154', found: '172'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -