QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227716#5415. RopewayxxcdsgCompile Error//C++201.6kb2023-10-27 21:56:062023-10-27 21:56:07

Judging History

你现在查看的是最新测评结果

  • [2023-10-27 21:56:07]
  • 评测
  • [2023-10-27 21:56:06]
  • 提交

answer

// xxc
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ll long long
#define int long long
#define debug(x) cout << #x << ' ' << x << endl;

const int N = 5e5 + 10;

ll predp[N],sufdp[N];//选中这个位置,需要最小的价值

int a[N];

void test(){
	int n,k;cin >> n >> k;
	for(int i = 1;i <= n;i++) cin >> a[i];
	string s;cin >> s;
	s = ' ' + s;
	queue<pair<int,ll>> qu;
	qu.push({0,0});
	predp[0] = 0;
	for(int i = 1;i <= n;i++){
		predp[i] = qu.front().second + a[i];
		if(s[i] == '1') while(!qu.empty()) qu.pop();
		while(!qu.empty() && (i - qu.front().first >= k || qu.front().second > predp[i])) qu.pop();
		qu.push({i,predp[i]});
	}
	predp[n + 1] = qu.front().second;
	while(!qu.empty()) qu.pop();
	qu.push({n + 1,0});
	sufdp[n + 1] = 0;
	for(int i = n;i >= 1;i--){
		sufdp[i] = qu.front().second + a[i];
		if(s[i] == '1') while(!qu.empty()) qu.pop();
		while(!qu.empty() && (qu.front().first - i >= k || qu.front().second > sufdp[i])) qu.pop();
		qu.push({i,sufdp[i]});
	}
	sufdp[0] = qu.front().second;
	int q;cin >> q;
	for(int i = 1;i <= q;i++){
		int p,v;cin >> p >> v;
		if(s[p] == '1'){
			cout << sufdp[0] + v - a[p] << '\n';
		}else{
			ll ans = sufdp[p] + predp[p] + v - a[p] * 2;
			ll mi = sufdp[p + 1];
			int j = p + 1;
			for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
				while(j <= n + 1 && j - ii <= k) mi = min(sufdp[j],mi),j++;
				ans = min(predp[ii] + mi,ans);
			}
			cout << ans << '\n';
		}
	}
}

signed main(){
	IOS
	int t = 1;cin >> t;
	while(t--){
		test();
	}
}

Details

answer.code: In function ‘void test()’:
answer.code:51:41: error: no matching function for call to ‘max(int, long long int)’
   51 |                         for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
      |                                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:2:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:51:41: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   51 |                         for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
      |                                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:2:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:51:41: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   51 |                         for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
      |                                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:2:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:51:41: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   51 |                         for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
      |                                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:51:41: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   51 |                         for(int ii = max(0,p - k + 1);ii <= p - 1;ii++){
      |                                      ~~~^~~~~~~~~~~~~