# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165541 | 2019-11-27T12:21:52 Z | ArKCa | Cipele (COCI18_cipele) | C++17 | 1000 ms | 98680 KB |
#include<bits/stdc++.h> using namespace std; int n,k,m; int dizi1[5005],dizi2[5005],dp[5005][5005]; 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 && ( (n-(crr+1)) <= (m-(i+1)) );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<5002;i++){ for(int j=0;j<5002;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; } else 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 87 ms | 98424 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 90 ms | 98288 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 98424 KB | Output is correct |
2 | Correct | 94 ms | 98680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 98296 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1069 ms | 98556 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 98680 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1082 ms | 98552 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 91 ms | 98300 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 94 ms | 98336 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 96 ms | 98296 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |