답안 #165535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165535 2019-11-27T12:08:03 Z ArKCa Cipele (COCI18_cipele) C++17
0 / 90
243 ms 262148 KB
#include<bits/stdc++.h>

using namespace std;
int n,k,m;
int dizi1[10005],dizi2[10005],dp[10005][10005];

int dpf(int crr,int r){
	if(crr==(n-1)){
		int mn=INT_MAX;
		for(int i=r;i<m;i++){
			mn=min(mn,abs(dizi1[crr]-dizi2[i]) );
		}
		dp[crr][r]=mn;
		return dp[crr][r];	
	}
	if( (n-crr) > (m-r) ){
		return INT_MAX;
	}
	if(dp[crr][r]!=-1){
		return dp[crr][r];
	}
	int mn=INT_MAX;
	// printf("a\n");
	for(int i=r;i<m;i++){
		mn=min(mn,max( abs(dizi1[crr]-dizi2[i] ),dpf(crr+1,i+1) ) );
	}
	dp[crr][r]=mn;
	return dp[crr][r];
}

int main(){
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	for(int i=0;i<10002;i++){
		for(int j=0;j<10002;j++){
			dp[i][j]=-1;
		}
	}
	scanf("%d %d",&n,&m);
	if(n==m){
		int mx=0;
		for(int i=0;i<n;i++){
			scanf("%d",&dizi1[i]);
		}
		for(int i=0;i<n;i++){
			scanf("%d",&dizi2[i]);
		}
		sort(dizi1,dizi1+n);
		sort(dizi2,dizi2+m);
		for(int i=0;i<n;i++){
			mx=max(abs(dizi2[i]-dizi1[i]),mx);
		}
		printf("%d\n",mx );
		return 0;
	}
	if(n<m){
		for(int i=0;i<n;i++){
			scanf("%d",&dizi1[i]);
		}
		for(int i=0;i<m;i++){
			scanf("%d",&dizi2[i]);
		}
		sort(dizi1,dizi1+n);
		sort(dizi2,dizi2+m);
		printf("%d\n",dpf(0,0) );
		return 0;
	}
	else{
		for(int i=0;i<n;i++){
			scanf("%d",&dizi2[i]);
		}
		for(int i=0;i<m;i++){
			scanf("%d",&dizi1[i]);
		}
		swap(n,m);
		sort(dizi1,dizi1+n);
		sort(dizi2,dizi2+m);

		printf("%d\n",dpf(0,0) );
		return 0;	
	}
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
cipele.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi1[i]);
    ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi2[i]);
    ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:58:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi1[i]);
    ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:61:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi2[i]);
    ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:70:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi2[i]);
    ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:73:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&dizi1[i]);
    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 234 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 226 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 223 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 224 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 233 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 242 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 227 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 232 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 243 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -