답안 #766376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766376 2023-06-25T15:11:00 Z 1ne Bali Sculptures (APIO15_sculpture) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;cin>>n>>a>>b;
	vector<int>arr(n);
	for (int i = 0;i<n;++i){
		cin>>arr[i];
	}
	int vv = 0;                                   
	for (int i = 0;i<(1<<n);++i){
		int v = 0;
		for (int j = 0;j<n;){
			int cur = (i & (1<<k));
			int k = j;
			int ans = 0;
			while(k < n && (i & (1<<k)) == cur){
				ans+=arr[k];
				++k;
			}
			v|=ans;
			cnt++;	
		}
		if (cnt >= a && cnt <= b){
			vv = max(vv,v);
		}
	}
	cout<<vv<<'\n';
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:16:23: error: 'k' was not declared in this scope
   16 |    int cur = (i & (1<<k));
      |                       ^
sculpture.cpp:24:4: error: 'cnt' was not declared in this scope; did you mean 'int'?
   24 |    cnt++;
      |    ^~~
      |    int
sculpture.cpp:26:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
   26 |   if (cnt >= a && cnt <= b){
      |       ^~~
      |       int