Submission #29455

#TimeUsernameProblemLanguageResultExecution timeMemory
29455kdh9949Taxis (POI13_tak)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, t;
ll d, b, x, a[500010];

int main(){
	scanf("%lld%lld%d", &d, &b, &n);
	for(int i = 0; i < n; i++) scanf("%lld", a + i);
	sort(a, a + n, greater<int>());
	t = int(upper_bound(a, a + n, d - b, greater<int>()) - a - 1);
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(i == t) continue;
		x += max(0, a[i] - (b - x));
		cnt++;
		if(x >= m){
			printf("%d\n", cnt);
			return 0;
		}
		if(a[t] >= max(d - b, b + d - 2 * x)){
			printf("%d\n", cnt + 1);
			return 0;
		}
	}
	puts("0");
}

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:16:29: error: no matching function for call to 'max(int, ll)'
   x += max(0, a[i] - (b - x));
                             ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from tak.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
tak.cpp:16:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   x += max(0, a[i] - (b - x));
                             ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from tak.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
tak.cpp:16:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   x += max(0, a[i] - (b - x));
                             ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from tak.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3457:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3457:5: note:   template argument deduction/substitution failed:
tak.cpp:16:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   x += max(0, a[i] - (b - x));
                             ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from tak.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   template argument deduction/substitution failed:
tak.cpp:16:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   x += max(0, a[i] - (b - x));
                             ^
tak.cpp:18:11: error: 'm' was not declared in this scope
   if(x >= m){
           ^
tak.cpp:9:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%d", &d, &b, &n);
                                 ^
tak.cpp:10:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%lld", a + i);
                                                 ^