Submission #464812

#TimeUsernameProblemLanguageResultExecution timeMemory
464812kaxzertSalesman (IOI09_salesman)C++17
Compilation error
0 ms0 KiB
/** 00 00 11 00 00 111111 00000 111111 000000 00 00 1111 0000 11 00 11 11 000000 0000 11 11 00 11 00000 111111 00 00 00 11111111 0000 11 00 11 11 00 00 00 11 11 00 00 111111 00000 11 11 00 **/ #include<bits/stdc++.h> using namespace std; void setIO(string s) { freopen((s+".inp").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } void setIOusaco(string s) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } #define fto(i, a, b) for(int i = a; i <= b; ++i) #define fdto(i, a, b) for(int i = a; i >= b; --i) #define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl; #define ll long long #define db double #define ldb long double #define ii pair<int, int> #define ff first #define ss second #define pb push_back #define mp make_pair #define eb emplace_back #define vt vector #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define trav(i, a) for(auto &i : a) #define sz(a) (int)a.size() #define fast ios::sync_with_stdio(false); cin.tie(0) void print(int x) {cout << x;} void print(long long x) {cout << x;} void print(unsigned x) {cout << x;} void print(unsigned long long x) {cout << x;} void print(double x) {cout << fixed << x;} void print(long double x) {cout << fixed << x;} void print(char x) {cout << "'" << x << "'";} void print(string x) {cout << '"' << x << '"';} void print(bool x) {cout << (x ? "true" : "false");} template<typename T, typename V> void print(const pair<T, V> &x) {cout << '{'; print(x.ff); cout << ", "; print(x.ss); cout << '}';} template<typename T> void print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? ", " : ""), print(i); cout << "}";} void _print() {cout << "]" << endl;} template <typename T, typename... V> void _print(T t, V... v) {print(t); if (sizeof...(v)) cout << ", "; _print(v...);} #ifdef TAP #define bug(x...) cout << "[" << #x << "] = ["; _print(x) #else #define bug(x...) #endif template<typename T, typename V> bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;} template<typename T, typename V> bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;} #define maxN 500008 const ll oo = (ll)1e16; ll f[maxN]; int n, u, d, s; struct segment_tree { vt<ll> nodes; segment_tree() { nodes.assign(n*4, -oo); } void update(int i, ll val, int root = 1, int left = 1, int right = n) { if (left == right && left == i) { nodes[root] = max(nodes[root], val); return; } if (left > i || right < i) return; int mid = (left+right)/2; update(i, val, root*2, left, mid); update(i, val, root*2+1, mid+1, right); nodes[root] = max(nodes[root*2], nodes[root*2+1]); } ll getquery(int i, int j, int root = 1, int left = 1, int right = n) { if (left >= i && right <= j) return nodes[root]; if (left > j || right < i) return -oo; int mid = (left+right)/2; return max(getquery(i, j, root*2, left, mid), getquery(i, j, root*2+1, mid+1, right)); } }; int main() { fast; cin >> n >> u >> d >> s; vt<array<int, 3> > a; vt<int> b; b.pb(s); fto(i, 1, n) { int day, loc, cost; cin >> day >> loc >> cost; a.pb({day, loc, cost}); b.pb(loc); } a.pb({600000, s, 0}); sort(all(a), [](array<int, 3> a, array<int, 3> b) { return a[0] < b[0]; }); sort(all(b)); b.erase(unique(all(b)), b.end()); n = sz(b); segment_tree up, down; auto tk = [=](int loc) -> int{ return ((lower_bound(all(b), loc))-b.begin()) + 1; }; int sth = tk(s); up.update(sth, -u*s); down.update(sth, d*s); // trav(c, a) { // bug(c); // } ll temp; trav(c, a) { int loc = tk(c[1]); //bug(loc); temp = up.getquery(loc+1, n) + c[1]*u + c[2]; //bug(temp); temp = max(temp, down.getquery(1, loc-1) -c[1]*d + c[2]); //bug(temp); up.update(loc, temp - u*c[1]); down.update(loc, temp + d*c[1]); } cout << max(temp, 0) << '\n'; return 0; }

Compilation message (stderr)

salesman.cpp: In function 'int main()':
salesman.cpp:157:24: error: no matching function for call to 'max(long long int&, int)'
  157 |     cout << max(temp, 0) << '\n';
      |                        ^
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 salesman.cpp:9:
/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:
salesman.cpp:157:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  157 |     cout << max(temp, 0) << '\n';
      |                        ^
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 salesman.cpp:9:
/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:
salesman.cpp:157:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  157 |     cout << max(temp, 0) << '\n';
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from salesman.cpp:9:
/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:
salesman.cpp:157:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  157 |     cout << max(temp, 0) << '\n';
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from salesman.cpp:9:
/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:
salesman.cpp:157:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  157 |     cout << max(temp, 0) << '\n';
      |                        ^
salesman.cpp: In function 'void setIO(std::string)':
salesman.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen((s+".inp").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
salesman.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
salesman.cpp: In function 'void setIOusaco(std::string)':
salesman.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen((s+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
salesman.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen((s+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~