#include<bits/stdc++.h>
using namespace std;
const int N=(int)5e3+5,INF=0x3f3f3f3f;
int dp[N][N],res=INF;
void solve(int x,int y,vector<int>& buyuk,vector<int>& kucuk,int fark,int sinbu,int sinku){
if(dp[x][y]<fark || sinku-y>sinbu-x)
return;
if(!(sinku-y)){
res=min(res,fark);
return;
}
if(x>=sinbu)
return;
if(dp[x][y]==INF && fark!=-1)
dp[x][y]=fark;
solve(x+1,y,buyuk,kucuk,fark,sinbu,sinku);
solve(x+1,y+1,buyuk,kucuk,max(fark,abs(buyuk[x]-kucuk[y])),sinbu,sinku);
}
int main(){
memset(dp,0x3f,sizeof dp);
int n,m,a;
vector<int> v1,v2;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d",&a);
v1.push_back(a);
}
for(int i=0;i<m;i++){
scanf("%d",&a);
v2.push_back(a);
}
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
if(n>=m)
solve(0,0,v1,v2,-1,n,m);
else
solve(0,0,v2,v1,-1,m,n);
printf("%d\n",res);
return 0;
}
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&m);
~~~~~^~~~~~~~~~~~~~~
cipele.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a);
~~~~~^~~~~~~~~
cipele.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
114 ms |
99568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
143 ms |
99572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
127 ms |
99572 KB |
Output is correct |
2 |
Execution timed out |
1069 ms |
99572 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
99572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
99572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1089 ms |
99572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
99572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
263 ms |
199264 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
261 ms |
199396 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
259 ms |
199424 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |