Submission #637520

# Submission time Handle Problem Language Result Execution time Memory
637520 2022-09-02T11:13:47 Z NotLinux Cipele (COCI18_cipele) C++14
0 / 90
134 ms 262144 KB
/**
 * author: NotLinux
 * created: 02.09.2022 ~ 13:30:25
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
    #include "/home/notlinux/debug.h"
#else
    #define debug(x...) void(37)
#endif
void solve(){
    int n,m;cin >> n >> m;
    vector < int > a(n),b(m);
    for(auto &inp : a)cin >> inp;
    for(auto &inp : b)cin >> inp;
    if(n > m){
        vector < int > tempv = a;
        a = b;
        b = tempv;
        int tempa = n;
        n = m;
        m = tempa;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    const int inf = 1e9+7;
    vector < vector < int > > dp(n , vector < int > (m,inf));
    vector < vector < int > > pre(n , vector < int > (m+2,inf));
    for(int i = 0;i<m;i++){
        dp[0][i] = abs(a[0]-b[i]);
        pre[0][i+1] = min(pre[0][i] , dp[0][i]);
    }
    for(int i = 1;i<n;i++){
        for(int j = 0;j<m;j++){
            dp[i][j] = max(pre[i-1][j] , abs(a[i]-b[j]));
            pre[i][j+1] = min(pre[i][j] , dp[i][j]);
        }
    }
    for(int i = 0;i<n;i++){
        debug(dp[i]);
    }
    cout << *min_element(dp[n-1].begin(),dp[n-1].end()) << endl;
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt=1;
    //cin >> tt;
    while(tt--)solve();
}

# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 134 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 98372 KB Output is correct
2 Runtime error 106 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8148 KB Output is correct
2 Runtime error 108 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 97 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 106 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 108 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 125 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -