답안 #766378

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766378 2023-06-25T15:11:19 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;
      	int cnt = 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:17:23: error: 'k' was not declared in this scope
   17 |    int cur = (i & (1<<k));
      |                       ^