Submission #1331259

#TimeUsernameProblemLanguageResultExecution timeMemory
1331259nguyenkhangninh99Measures (CEOI22_measures)C++17
Compilation error
0 ms0 KiB
include<bits/stdc++.h>
using namespace std;

#define int long long 
const int maxn = 5e5 + 5;
struct node{
    int a, b, cnt, mx;
} st[4 * maxn];
int n, m, d;
node merge(node l, node r){
    return {min(r.a, l.a - d * r.cnt), max(r.b + l.cnt * d, l.b), l.cnt + r.cnt, max({l.mx, r.mx, r.b - l.a})};
}
void update(int id, int l, int r, int p, int val){
    if(l == r) st[id].a = -val, st[id].b = d - val, st[id].cnt = 1;
    else{
        int mid = (l + r) / 2;
        if(p <= mid) update(id * 2, l, mid, p, val);
        else update(id * 2 + 1, mid + 1, r, p, val);
        st[id] = merge(st[id * 2], st[id * 2 + 1]);
    }
}
void solve(){
    cin >> n >> m >> d;
    vector<int> order(n + m + 1), a(n + m + 1);
    for(int i = 1; i <= n + m; i++) cin >> a[i];
    for(int i = 1; i <= n + m; i++) order[i] = i;

    sort(order.begin() + 1, order.end(), [&](int x, int y){
        return a[x] < a[y] || (a[x] == a[y] && x < y);
    });
    
    for(int i = 1; i < 4 * maxn; i++) st[i].a = 1e18, st[i].mx = 0, st[i].b = -1e18, st[i].cnt = 0;
    for(int i = 1; i <= n + m; i++){
        update(1, 1, n + m, order[i], a[i]);
        if(i > n){
            cout << st[1].mx / 2;
            if(st[1].mx % 2 == 1) cout << ".5";
            cout << " ";

        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    solve();
}

Compilation message (stderr)

Main.cpp:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
Main.cpp: In function 'node merge(node, node)':
Main.cpp:11:13: error: 'min' was not declared in this scope
   11 |     return {min(r.a, l.a - d * r.cnt), max(r.b + l.cnt * d, l.b), l.cnt + r.cnt, max({l.mx, r.mx, r.b - l.a})};
      |             ^~~
Main.cpp:11:40: error: 'max' was not declared in this scope; did you mean 'maxn'?
   11 |     return {min(r.a, l.a - d * r.cnt), max(r.b + l.cnt * d, l.b), l.cnt + r.cnt, max({l.mx, r.mx, r.b - l.a})};
      |                                        ^~~
      |                                        maxn
Main.cpp:11:110: error: could not convert '{<expression error>, <expression error>, (l.node::cnt + r.node::cnt), <expression error>}' from '<brace-enclosed initializer list>' to 'node'
   11 |     return {min(r.a, l.a - d * r.cnt), max(r.b + l.cnt * d, l.b), l.cnt + r.cnt, max({l.mx, r.mx, r.b - l.a})};
      |                                                                                                              ^
      |                                                                                                              |
      |                                                                                                              <brace-enclosed initializer list>
Main.cpp: In function 'void solve()':
Main.cpp:23:5: error: 'cin' was not declared in this scope
   23 |     cin >> n >> m >> d;
      |     ^~~
Main.cpp:24:5: error: 'vector' was not declared in this scope
   24 |     vector<int> order(n + m + 1), a(n + m + 1);
      |     ^~~~~~
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:24:12: note: in expansion of macro 'int'
   24 |     vector<int> order(n + m + 1), a(n + m + 1);
      |            ^~~
Main.cpp:25:44: error: 'a' was not declared in this scope
   25 |     for(int i = 1; i <= n + m; i++) cin >> a[i];
      |                                            ^
Main.cpp:26:37: error: 'order' was not declared in this scope
   26 |     for(int i = 1; i <= n + m; i++) order[i] = i;
      |                                     ^~~~~
Main.cpp:28:10: error: 'order' was not declared in this scope
   28 |     sort(order.begin() + 1, order.end(), [&](int x, int y){
      |          ^~~~~
Main.cpp: In lambda function:
Main.cpp:29:16: error: 'a' was not declared in this scope
   29 |         return a[x] < a[y] || (a[x] == a[y] && x < y);
      |                ^
Main.cpp: In function 'void solve()':
Main.cpp:28:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |     sort(order.begin() + 1, order.end(), [&](int x, int y){
      |     ^~~~
      |     short
Main.cpp:34:39: error: 'a' was not declared in this scope
   34 |         update(1, 1, n + m, order[i], a[i]);
      |                                       ^
Main.cpp:36:13: error: 'cout' was not declared in this scope
   36 |             cout << st[1].mx / 2;
      |             ^~~~
Main.cpp: In function 'int main()':
Main.cpp:44:5: error: 'ios_base' has not been declared
   44 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
Main.cpp:45:5: error: 'cin' was not declared in this scope
   45 |     cin.tie(0); cout.tie(0);
      |     ^~~
Main.cpp:45:17: error: 'cout' was not declared in this scope
   45 |     cin.tie(0); cout.tie(0);
      |                 ^~~~