Submission #464655

# Submission time Handle Problem Language Result Execution time Memory
464655 2021-08-13T15:16:59 Z ahmedfouadnew Cipele (COCI18_cipele) C++17
45 / 90
521 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int mod=1e9+7;
int a[5005],b[5005],n,m;
int dp[5005][5005];
int fun(int idx,int idx2)
{
    if(idx2==m)
    {
        return 0;
    }
    if(idx==n)
        return 1e15;
    int &ret=dp[idx][idx2];
    if(~ret)
        return ret;
    ret=1e15;
    ret=max(abs(a[idx]-b[idx2]),fun(idx+1,idx2+1));
    ret=min(ret,fun(idx+1,idx2));
    return ret;
}
signed main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    if(n<m)
    {
        for(int i=0;i<m;i++)
        {
            swap(a[i],b[i]);
        }
        swap(n,m);
    }
    sort(a,a+n);
    sort(b,b+m);
    cout<<fun(0,0)<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 319 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 323 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 167 ms 196552 KB Output is correct
2 Correct 517 ms 196764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 196612 KB Output is correct
2 Correct 516 ms 196768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 196712 KB Output is correct
2 Correct 518 ms 196764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 196712 KB Output is correct
2 Correct 495 ms 196764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 521 ms 196760 KB Output is correct
2 Correct 502 ms 196768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 326 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 332 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 323 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -