QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611708#8790. First BillionZhenAn9052Compile Error//C++14692b2024-10-04 22:14:242024-10-04 22:14:25

Judging History

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

  • [2024-10-04 22:14:25]
  • 评测
  • [2024-10-04 22:14:24]
  • 提交

answer

#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
const int N=100,M=1e9;
int n;
pair<int,int>a[N+5];
int num[N+5];
bool flag;
void dfs(int now,int cnt,int sum){
	if(flag)return;
	if(sum>M)return;
	if(M-sum>(n-now+1ll)*a[now].first)return;
	if(now>n){
		if(sum!=M)return;
		printf("%d ",cnt);flag=1;
		for(int i=1;i<=cnt;++i)printf("%d ",num[i]);
		return;
	}	
	for(int i=now;i<=n;++i){
		num[cnt+1]=a[i].second;
		dfs(i+1,cnt+1,sum+a[i].first);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i].first);
		a[i].second=i;tmp[i]=a[i].first;
	}
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	dfs(1,0,0);
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:29:31: error: ‘tmp’ was not declared in this scope
   29 |                 a[i].second=i;tmp[i]=a[i].first;
      |                               ^~~
answer.code:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                 scanf("%d",&a[i].first);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~