Submission #472366

# Submission time Handle Problem Language Result Execution time Memory
472366 2021-09-13T12:25:45 Z _L__ Cipele (COCI18_cipele) C++17
18 / 90
1000 ms 1868 KB
// This code is written by _L__
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 1e5+300, INF = 1e18;
const ld E = 1e-6;
 
int main(void){
    F_word;
    int n, m; cin >> n >> m;
    vector<int> l(n), r(m); for(int i = 0; i < n; ++i) cin >> l[i]; for(int i =0 ; i < m; ++i) cin >> r[i];
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());
    if(n <= m){
        ll ans = 0;
        for(int i = 0; i < n; ++i){
            ll idx = 0, b = INT_MAX;
            for(int j = 0; j < r.size(); ++j){
                if(abs(r[j]-l[i]) <= b){
                    b = abs(r[j]-l[i]);
                    idx = j;
                } else break;
            }
            r.erase(r.begin()+idx);
            ans = max(ans, b);
        }
        cout << ans << endl;
    } else {
        ll ans = 0;
        for(int i = 0; i < m; ++i){
            ll idx = 0, b = INT_MAX;
            for(int j =0;j < l.size(); ++j){
                if(abs(l[j]-r[i]) <= b){
                    idx = j;
                    b = abs(r[i]-l[j]);
                } else break;
            }
            l.erase(l.begin()+idx);
            ans = max(ans, b);
        }
        cout << ans << endl;
    }
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(int j = 0; j < r.size(); ++j){
      |                            ~~^~~~~~~~~~
cipele.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j =0;j < l.size(); ++j){
      |                          ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 863 ms 1868 KB Output is correct
2 Incorrect 927 ms 1868 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 951 ms 1860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 1612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 1656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1604 KB Time limit exceeded
2 Halted 0 ms 0 KB -