Submission #637519

# Submission time Handle Problem Language Result Execution time Memory
637519 2022-09-02T11:12:15 Z NotLinux Cipele (COCI18_cipele) C++14
0 / 90
131 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;
    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 124 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 129 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 98428 KB Output is correct
2 Runtime error 100 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8192 KB Output is correct
2 Runtime error 107 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 262144 KB Execution killed with signal 9
2 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 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 121 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 127 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -