QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139647#5405. 爬楼梯1kri#Compile Error//C++14851b2023-08-14 08:54:112024-07-04 01:41:41

Judging History

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

  • [2024-07-04 01:41:41]
  • 评测
  • [2023-08-14 08:54:11]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
int n,m;
int a[200005];
int l,r;
int len,c[200005];
struct node{
	int 
};
ll work(){
	ll ans=0;
	sort(c+1,c+1+len);
	if (len&1){
		int mid=(len+1)/2;
		for (int i=1;i<=len;i++)ans+=2ll*c[i];
		for (int i=1;i<mid;i++)ans-=4ll*c[i];
		ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
	}
	else{
		int mid=len/2;
		for (int i=1;i<=len;i++)ans+=2ll*c[i];
		for (int i=1;i<=mid;i++)ans-=4ll*c[i];
		ans-=c[mid+1];
		ans+=c[mid];
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	while(m--){
		scanf("%d%d",&l,&r);
		len=0;
		for (int i=l;i<=r;i++)c[++len]=a[i];
		sort(c+1,c+1+len);
		ll ans=0;
		ans+=work();
		printf("%lld\n",ans);
	}
	return 0;
} 

詳細信息

answer.code:13:1: error: expected unqualified-id before ‘}’ token
   13 | };
      | ^
answer.code: In function ‘long long int work()’:
answer.code:21:25: error: no matching function for call to ‘min(int, long long int)’
   21 |                 ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:21:25: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   21 |                 ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:21:25: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   21 |                 ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from answer.code:3:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:21:25: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   21 |                 ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:21:25: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   21 |                 ans-=min(c[mid]+c[mid+1],3ll*c[mid]-c[mid-1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
answer.code:34:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         for (int i=1;i<=n;i++)scanf("%d",&a[i]);
      |                               ~~~~~^~~~~~~~~~~~
answer.code:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%d%d",&l,&r);
      |                 ~~~~~^~~~~~~~~~~~~~