QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#756844#5122. Strange Sumhikaritocm#Compile Error//C++141.0kb2024-11-16 22:15:162024-11-16 22:15:18

Judging History

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

  • [2024-11-16 22:15:18]
  • 评测
  • [2024-11-16 22:15:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> tree(400005,-1e9-5);
void upd(int node, int l, int r, int pos, int val){
	if(l==r) tree[node]=val;
	else{
		int mid=(l+r)/2;
		if(pos<=mid)upd(node*2,l,mid,pos,val);
		else upd(node*2+1,mid+1,r,pos,val);
		tree[node]=max(tree[node*2],tree[node*2+1]);
	}
}
int query(int node, int l, int r, int lx, int rx){
	if(lx<=l and r<=rx){
		return tree[node];
	}
	if(r<lx or rx<l){
		return -1e9-5;
	}
	int mid=(l+r)/2;
	return max(query(node*2,l,mid,lx,rx),query(node*2+1,mid+1,r,lx,rx));
}
void solve(){
	int n;
	cin>>n;
	int ans=a[n];
	ans=max(ans,0);
	vector<int> a(n+1);
	vector<int> mx(n+1);
	for(int i=1; i<=n; i++){
		cin>>a[i];
		upd(1,1,n,i,a[i]);
//		ans=max(ans,a[i]+)
	}
	for(int i=1; i<=n-1; i++){
		int j=i+i-1;
		j=min(j,n);
		ans=max(ans,a[i]+query(1,1,n,i+1,j));
	}
	cout<<ans<<endl;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
//	cin>>t;
	while(t--) solve();
}

详细

answer.code: In function ‘void solve()’:
answer.code:27:17: error: ‘a’ was not declared in this scope
   27 |         int ans=a[n];
      |                 ^
answer.code:28:16: error: no matching function for call to ‘max(long long int&, int)’
   28 |         ans=max(ans,0);
      |             ~~~^~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:28:16: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   28 |         ans=max(ans,0);
      |             ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:28:16: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   28 |         ans=max(ans,0);
      |             ~~~^~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:28:16: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   28 |         ans=max(ans,0);
      |             ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:28:16: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   28 |         ans=max(ans,0);
      |             ~~~^~~~~~~