# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99536 | 2019-03-04T19:54:10 Z | Sa1loum | Cipele (COCI18_cipele) | C++14 | 1000 ms | 5496 KB |
#include <bits/stdc++.h> using namespace std; #define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define mem(a,b) memset(a, b, sizeof(a)) #define F first #define S second #define Si size #define pb(x) push_back(x) typedef double D; typedef long long ll; typedef long double ld; const int MOD=(int)1e9+7,MAX=(int)1e5+10; int n,m,a[MAX],b[MAX]; int DP(int i,int j) { if (i==n-1 && j==m-1) return abs(a[i]-b[j]); if (i==n-1) return min(DP(i,j+1),abs(a[i]-b[j])); if (j==m-1) return abs(a[i]-b[j]); return min(DP(i,j+1),max(DP(i+1,j+1),abs(a[i]-b[j]))); } int main() { scanf("%d%d",&n,&m); if (n<m) { for (int i=0;i<n;i++) { scanf("%d",&a[i]); } for (int i=0;i<m;i++) { scanf("%d",&b[i]); } } else { for (int i=0;i<n;i++) { scanf("%d",&b[i]); } for (int i=0;i<m;i++) { scanf("%d",&a[i]); } swap(n,m); } sort(a,a+n); sort(b,b+m); if (n==m) { int mx=-1; for (int i=0;i<n;i++) { int o=fabs(a[i]-b[i]); mx=max(mx,o); } cout<<mx<<endl; return 0; } cout<<DP(0,0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 1144 KB | Output is correct |
2 | Correct | 50 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 1172 KB | Output is correct |
2 | Correct | 47 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 512 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1089 ms | 512 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1074 ms | 640 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1072 ms | 512 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1064 ms | 640 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1071 ms | 5496 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 5444 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 5240 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |