답안 #436002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436002 2021-06-24T04:55:04 Z chirathnirodha Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 204 KB
//Coded by Chirath Nirodha
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod=1e9+7;
inline void io(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
void solve(){
	int n,a,b;cin>>n>>a>>b;
	ll arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
    ll dp[n][n+1];
	for(int i=0;i<n;i++)for(int j=0;j<=n;j++)dp[i][j]=INT64_MAX;
	dp[0][1]=arr[0];
	for(int i=1;i<n;i++){
		ll cur=0;
		for(int j=i-1;j>=0;j--){
			cur+=arr[j+1];
			for(int k=1;k<=j+1;k++){
				dp[i][k+1]=min(dp[i][k+1],dp[j][k]|cur);
			}
		}
		dp[i][1]=cur+arr[0];
	}
	ll ans=INT64_MAX;
	for(int i=a;i<=b;i++)ans=min(ans,dp[n-1][i]);
	cout<<ans<<endl;
}
int main(){
    io();
	solve();
	//int t;cin>>t;for(int i=0;i<t;i++)solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -