답안 #498999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498999 2021-12-27T02:44:33 Z amukkalir Bali Sculptures (APIO15_sculpture) C++17
0 / 100
103 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 

const int INF = INT_MAX; 
const int nax = 2000; 
int a, b, n; 
ll y[nax+5]; 
int dp[51][505][550][25]; 

int f(int idx, ll sum, ll val, int grup) {
	if(grup > 20) return INF; 

	int &res = dp[idx][sum][val][grup]; 
	if(~res) return res; 

	if(idx==n) res = (a <= grup && grup <= b) ? (val | (sum + y[n])) : INF; 
	else res = min(f(idx+1, sum+y[idx], val, grup), f(idx+1, 0, val | (sum+y[idx]), grup+1)); 

	//cerr << idx << ' ' << sum << " " << val << " " << grup << " " << res << endl; 
	return res; 
}

int main() {
	scanf("%d %d %d", &n, &a, &b); 
	for(int i=1; i<=n; i++) {
		scanf("%lld", &y[i]); 
	}
	memset(dp, -1, sizeof (dp)); 

	printf("%d", f(1, 0, 0, 1)); 
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  scanf("%d %d %d", &n, &a, &b);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%lld", &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 93 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 92 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -