Submission #542290

# Submission time Handle Problem Language Result Execution time Memory
542290 2022-03-26T04:56:29 Z SirCovidThe19th Meteors (POI11_met) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std; 

#define FOR(i, x, y) for (int i = x; i < y; i++)
#define ll long long

const int mx = 3e5 + 5;

int n, m, q, targ[mx], ans[mx]; ll bit[mx]; vector<int> pos[mx]; array<int, 3> Q[mx]; 

void upd(int i, int val){
    for (; i < mx; i += i & (-i)) bit[i] += val;
}
void rupd(int l, int r, int val){
    if (l <= r) upd(l, val), upd(r + 1, -val);
    else rupd(l, m, val), rupd(1, r, val);
}
ll qry(int i){
    ll ret = 0;
    for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
    return ret;
}
void pbs(int l, int r, vector<pair<int, ll>> states){
    if (l == r or states.empty()){
        for (auto [i, _] : states) ans[i] = l;
        return;
    }
    int mid = (l + r) / 2; vector<pair<int, ll>> L, R;

    FOR(i, l, mid + 1) rupd(Q[i][0], Q[i][1], Q[i][2]);
    for (auto [i, initVal] : states){
        ll sm = initVal;
        for (int p : pos[i]) sm += qry(p);
        (sm >= targ[i]) ? L.push_back({i, initVal}) : R.push_back({i, sm});
    }
    FOR(i, l, mid + 1) rupd(Q[i][0], Q[i][1], -Q[i][2]);

    pbs(l, mid, L); pbs(mid + 1, r, R);
}

int main(){
    cin >> n >> m;
    FOR(i, 1, m + 1){ int x; cin >> x; pos[x].push_back(i); }
    FOR(i, 1, n + 1) cin >> targ[i];
    cin >> q;
    FOR(i, 1, q + 1) cin >> Q[i][0] >> Q[i][1] >> Q[i][2];

    vector<pair<int, ll>> all;
    FOR(i, 1, n + 1) all.push_back({i, 0});
    pbs(1, q + 1, all);
    FOR(i, 1, n + 1) cout<<(ans[i] <= q ? to_string(ans[i]) : "NIE")<<"\n";
}

Compilation message

met.cpp: In function 'long long int qry(int)':
met.cpp:20:67: error: no matching function for call to 'min(long long int&, double)'
   20 |     for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
      |                                                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:20:67: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   20 |     for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
      |                                                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:20:67: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   20 |     for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
      |                                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:20:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |     for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
      |                                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:20:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |     for (; i > 0; i -= i & (-i)) ret += bit[i], ret = min(ret, 1e9); //avoid overflow
      |                                                                   ^