QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301673#5475. Make a LoopwxhtzdyCompile Error//C++20692b2024-01-10 04:25:542024-01-10 04:25:54

Judging History

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

  • [2024-01-10 04:25:54]
  • 评测
  • [2024-01-10 04:25:54]
  • 提交

answer

#include <stdio.h>
#include <algorithm>

unsigned char min(unsigned char a, unsigned char b) { return a < b ? a : b; }

int s,j;
short int a[101];
unsigned char n,i,dp[2][500005];

int main(){
scanf("%hhu",&n);
s=0;
for(i=1;i<=n;i++) scanf("%hd",a+i),s+=a[i];
sort(a+1,a+n+1);
reverse(a+1,a+n+1);
if(s%2==1){
printf("No");
return 0;
}
s>>=1;
	dp[0][0]=1;
	int ns=0;
	for(i=1;i<=n;i++){
		ns+=a[i];
if(ns>s) ns=s;
		for(j=ns;j>=a[i];j--){
			
				dp[0][j]=dp[0][j]+dp[1][j-a[i]];
if (dp[0][j] > 4) dp[0][j] = 4;
				dp[1][j]=dp[1][j]+dp[0][j-a[i]];
if (dp[1][j] > 4) dp[1][j] = 4;
		}
	}
	if(n%2==1||dp[0][s]<4) printf("No"); else printf("Yes");
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:14:1: error: ‘sort’ was not declared in this scope
   14 | sort(a+1,a+n+1);
      | ^~~~
answer.code:14:1: note: suggested alternatives:
In file included from /usr/include/c++/11/algorithm:74,
                 from answer.code:2:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:296:1: note:   ‘std::sort’
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
In file included from /usr/include/c++/11/algorithm:64,
                 from answer.code:2:
/usr/include/c++/11/bits/ranges_algo.h:1834:30: note:   ‘std::ranges::sort’
 1834 |   inline constexpr __sort_fn sort{};
      |                              ^~~~
answer.code:15:1: error: ‘reverse’ was not declared in this scope
   15 | reverse(a+1,a+n+1);
      | ^~~~~~~
answer.code:15:1: note: suggested alternatives:
In file included from /usr/include/c++/11/algorithm:74,
                 from answer.code:2:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:249:1: note:   ‘std::reverse’
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
In file included from /usr/include/c++/11/algorithm:64,
                 from answer.code:2:
/usr/include/c++/11/bits/ranges_algo.h:1325:33: note:   ‘std::ranges::reverse’
 1325 |   inline constexpr __reverse_fn reverse{};
      |                                 ^~~~~~~
answer.code:11:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 | scanf("%hhu",&n);
      | ~~~~~^~~~~~~~~~~
answer.code:13:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 | for(i=1;i<=n;i++) scanf("%hd",a+i),s+=a[i];
      |                   ~~~~~^~~~~~~~~~~