답안 #978699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978699 2024-05-09T14:09:46 Z SmuggingSpun Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define taskname "sculpture"
using namespace std;
template<class T>void minimize(T& a, T b){
	if(a > b){
		a = b;
	}
}
int n, a, b;
vector<int>y;
namespace sub1{
	void solve(){
		int ans = INT_MAX;
		for(int mask = (1 << n) - 2; mask > -1; mask -= 2){
			int value = 0, cnt_1 = __builtin_popcount(mask), sum = 0;
			if(a <= cnt_1 && cnt_1 <= b){
				for(int i = 0; i < n; i++){
					if(1 << i & mask){
						value |= sum;
						sum = 0;
					}
					sum += y[++i];
				}
				minimize(ans, value | sum);
			}
		}
		cout << ans;
	}
}
namespace sub23{
	void solve(){
		
	}
}
namespace sub45{
	void solve(){
		
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	cin >> n >> a >> b;
	y.resize(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> y[i];
	}
	if(n <= 20){
		sub1::solve();
	}
	else if(n <= 100 && *max_element(y.begin() + 1, y.end()) <= 20){
		sub23::solve();
	}
	else{
		sub45::solve();
	}
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:43:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -