Submission #848521

#TimeUsernameProblemLanguageResultExecution timeMemory
848521NaserOvertaking (IOI23_overtaking)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
//#define int long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<long long>
#define vpii vector<pii>
#define pb push_back
#define se second
#define fi first
#define all(x) x.begin(), x.end()
#define graph vector<vector<int>>
using namespace std;
const int N = (int)2e5 + 69;
const int mod = (int)1e4 + 7;
const int naser = 3999, tourist = 3816;
int power(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return ans; }

int ex[1001][1001], ti[1001][1001], y, x, n, m;
vint tmp, t, w, s;
bool cmp(int a, int b) {
	int aa = (y - t[a]) / (w[a] - x);
	int bb = (y - t[b]) / (w[b] - x);
	if (min(aa, bb) < 0)
		return aa > bb;
	return aa < bb;
}
void init(int l, int N, vint T, vint W, int X, int M, vint S) {
	t = T;
	w = W;
	s = S;
	x = X;
	n = N;
	m = M;
	tmp.resize(n);
	for (int i = 0; i < m; i++)
		ti[i][0] = t[i];
	for (int j = 1; j < m; j++) {
		for (int i = 0; i < n; i++) {
			ex[i][j] = ti[i][j-1] + (s[j] - s[j - 1]) * w[i];
		}
		for (int i = 0; i < n; i++) {
			ti[i][j] = ex[i][j];
			for (int k = 0; k < n; k++) {
				if (ti[k][j - 1] < ti[i][j - 1])
					ti[i][j] = max(ex[i][j], ex[k][j]);
			}
		}
	}
	for (int i = 0; i < n; i++)
		tmp[i] = i;
}
long long arrival_time(int Y) {
	y = Y;
	int arrive[1001] = {};
	sort(all(tmp),cmp);
	int it = 1;
	arrive[0] = y;
	for (int i = 0; i < n; i++) {
		int cross = (y - t[tmp[i]]) / (w[tmp[i]] - x);
		int idx = lower_bound(all(s),cross) - s.begin();
		if (cross < 0)
			continue;
		while (it < m-1 && it < idx) {
			arrive[it] =  arrive[it - 1] + (s[it] - s[it - 1]) * x;
			it++;
		}
		if (idx == it && idx < m) {
			arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
			it++;
		}
	}
	while (it < m) {
		arrive[it] = arrive[it - 1] + (s[it] - s[it - 1]) * x;
		it++;
	}
	return arrive[m - 1];
}
//int32_t main() {
	
	//init(6, 4, { 20, 10, 40, 0 }, { 5, 20, 20, 30 }, 10, 4, { 0, 1, 3, 6 });
	//init(6, 2, { 10, 20 }, { 5, 3 }, 2, 2, { 0, 6 });
	//while (naser > tourist) {
	//	int y;
	//	cin >> y;
	//	cout << arrival_time(y) << endl;
	//}
	
//}

Compilation message (stderr)

overtaking.cpp: In function 'long long int arrival_time(int)':
overtaking.cpp:68:77: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   68 |    arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
      |                                                                             ^
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 overtaking.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:
overtaking.cpp:68:77: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   68 |    arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
      |                                                                             ^
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 overtaking.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:
overtaking.cpp:68:77: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   68 |    arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
      |                                                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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:
overtaking.cpp:68:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   68 |    arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
      |                                                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from overtaking.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:
overtaking.cpp:68:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   68 |    arrive[it] = max(ti[tmp[i]][it], arrive[it - 1] + (s[it] - s[it - 1]) * x);
      |                                                                             ^