QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301617#5475. Make a LoopwxhtzdyCompile Error//C++20440b2024-01-10 03:49:462024-01-10 03:49:47

Judging History

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

  • [2024-01-10 03:49:47]
  • 评测
  • [2024-01-10 03:49:46]
  • 提交

answer

#include <stdio.h>

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

int n,a[101],dp[2][1000005];

int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dp[0][0]=1;
	int s=0;
	for(int i=1;i<=n;i++){
		s+=a[i];
		for(int j=s;j>=x;j--){
			for(int f=0;f<2;f++){
				dp[f][j]=min(4,dp[f][j]+dp[f^1][j-a[i]]);
			}
		}
	}
	if(n%2==0&&s%2==0&&dp[0][s/2]>=4) printf("Yes\n"); else printf("No\n");
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:14:32: error: ‘x’ was not declared in this scope
   14 |                 for(int j=s;j>=x;j--){
      |                                ^
answer.code:8:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 | scanf("%d",&n);
      | ~~~~~^~~~~~~~~
answer.code:9:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                       ~~~~~^~~~~~~~~~~~