Submission #894998

# Submission time Handle Problem Language Result Execution time Memory
894998 2023-12-29T10:28:15 Z tamyte Bulldozer (JOI17_bulldozer) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define int int64_t
#define all(x) (x).begin(), (x).end()
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
using pii = std::pair<int, int>;
using namespace std;

void setIO(string name = "")
{
    cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
    if (name.size())
    {
        freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
int MOD = 1e9 + 7;
int oo = 1e18;



struct st
{
    int x, y, c;
};




void solve() {
    #define test1
    int n;
    cin >> n;
    vector<st> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].x >> arr[i].y >> arr[i].c;
    }
    sort(arr.begin(), arr.end(), [&](const st& a, const st& b) {
        return a.x < b.x;
    });
    int mx = 0, curr = 0;
    for (int i = 0; i < n; ++i) {
        // cout << arr[i].c << " -> ";
        curr = max(0LL, curr + arr[i].c);
        mx = max(mx, curr);
        // cout << curr << " -> ";
    }
    // cout << "\n";
    // cout << mx << " ";
    sort(arr.begin(), arr.end(), [&](const st& a, const st& b) {
        return a.y < b.y;
    });
    curr = 0;
    for (int i = 0; i < n; ++i) {
        curr = max(0LL, curr + arr[i].c);
        mx = max(mx, curr);
    }
    cout << mx;
} 




int32_t main () {
    setIO(""); int t = 1;
    #ifdef test
    cin >> t;
    #endif
    while (t--) solve();
}

Compilation message

bulldozer.cpp: In function 'void solve()':
bulldozer.cpp:45:40: error: no matching function for call to 'max(long long int, int64_t)'
   45 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   45 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   45 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
bulldozer.cpp:56:40: error: no matching function for call to 'max(long long int, int64_t)'
   56 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:56:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   56 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:56:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   56 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:56:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:56:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |         curr = max(0LL, curr + arr[i].c);
      |                                        ^
bulldozer.cpp: In function 'void setIO(std::string)':
bulldozer.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~