Submission #681506

# Submission time Handle Problem Language Result Execution time Memory
681506 2023-01-13T08:15:19 Z Vladth11 Cipele (COCI18_cipele) C++14
Compilation error
0 ms 0 KB
bugs(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
 
const int NMAX = 100001;
const int VMAX = 41;
const int INF = 1e9;
const int MOD = 1000000009;
const int BLOCK = 318;
const int base = 31;
const int nrbits = 21;
 
int a[NMAX], b[NMAX];
int n, m;
 
int f(int poz)
{
    if(poz + m - 1 > n) return 1e9;
    int maxim = 0;
    for(int i = 1; i <= m; i++){
        maxim = max(maxim, abs(a[i + poz - 1] - b[i]));
    }
    return maxim;
}
 
int ternary(int st, int dr){
    if(st >= dr - 2)
        return min({f(st), f(dr), f(st + 1)});
    int mid1 = st + (dr - st) / 3;
    int mid2 = dr - (dr - st) / 3;
    int f1 = f(mid1);
    int f2 = f(mid2);
    if(f1 < f2)
        return ternary(st, f2);
    return ternary(f1, dr);
}
 
int main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i;
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cin >> a[i];
    for(i = 1; i <= m; i++)
        cin >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + m + 1);
    if(m > n){
        for(i = 1; i <= m; i++){
            swap(a[i], b[i]);
        }
        swap(n, m);
    }
    cout << ternary(1, n - m + 1);
    return 0;
}

Compilation message

cipele.cpp:1:17: error: stray '#' in program
    1 | bugs(x) cerr << #x << " " << x << " "
      |                 ^
cipele.cpp:1:5: error: expected constructor, destructor, or type conversion before '(' token
    1 | bugs(x) cerr << #x << " " << x << " "
      |     ^
cipele.cpp:4:9: error: 'pair' does not name a type
    4 | typedef pair <int, int> pii;
      |         ^~~~
cipele.cpp: In function 'int f(int)':
cipele.cpp:23:28: error: 'abs' was not declared in this scope
   23 |         maxim = max(maxim, abs(a[i + poz - 1] - b[i]));
      |                            ^~~
cipele.cpp:23:17: error: 'max' was not declared in this scope; did you mean 'maxim'?
   23 |         maxim = max(maxim, abs(a[i + poz - 1] - b[i]));
      |                 ^~~
      |                 maxim
cipele.cpp: In function 'int ternary(int, int)':
cipele.cpp:30:16: error: 'min' was not declared in this scope
   30 |         return min({f(st), f(dr), f(st + 1)});
      |                ^~~
cipele.cpp: In function 'int main()':
cipele.cpp:45:5: error: 'ios_base' has not been declared
   45 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
cipele.cpp:46:5: error: 'cin' was not declared in this scope
   46 |     cin.tie(0);
      |     ^~~
cipele.cpp:47:5: error: 'cout' was not declared in this scope
   47 |     cout.tie(0);
      |     ^~~~
cipele.cpp:54:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   54 |     sort(a + 1, a + n + 1);
      |     ^~~~
      |     short
cipele.cpp:58:13: error: 'swap' was not declared in this scope
   58 |             swap(a[i], b[i]);
      |             ^~~~
cipele.cpp:60:9: error: 'swap' was not declared in this scope
   60 |         swap(n, m);
      |         ^~~~