답안 #527573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527573 2022-02-17T17:04:02 Z SlavicG Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 ms 3148 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 500, K = 50;
int p[N];
int sum(int l, int r) {
    return p[r] - (l ? p[l - 1] : 0);
}

//dp[index][OR][number of subarrays] = 1 if possible to obtain such partition

int dp[N][2 * K + 1][N];
void solve() { 
    int n, A, B;
    cin >> n >> A >> B;
    vector<int> a(n);
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        p[i] = (i ? p[i - 1] : 0) + a[i];
    }

    dp[0][0][0] = 1;

    for(int i = 1; i <= n; ++i) {
        for(int j = 0;j < i; ++j) {
            for(int OR = 0; OR < K; ++OR) {
                int s = sum(j, i - 1);
                for(int k = 0; k < B; ++k) {
                    dp[i][OR | s][k + 1] |= dp[j][OR][k]; 
                }
            }
        }
    }
    int ans = INT_MAX;
    for(int i = A; i <= B; ++i) {
        for(int OR = 0; OR < 2 * K + 1; ++OR) {
            if(dp[n][OR][i]) ans = min(ans, OR);
        }
    }
    cout << ans << "\n";
} 
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 844 KB Output is correct
2 Correct 1 ms 1084 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1868 KB Output is correct
7 Correct 1 ms 2380 KB Output is correct
8 Correct 1 ms 2628 KB Output is correct
9 Incorrect 2 ms 3148 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 824 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 388 KB Output is correct
4 Correct 1 ms 568 KB Output is correct
5 Correct 1 ms 1216 KB Output is correct
6 Correct 1 ms 1824 KB Output is correct
7 Correct 1 ms 2380 KB Output is correct
8 Correct 1 ms 2508 KB Output is correct
9 Incorrect 2 ms 3148 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 844 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 580 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1868 KB Output is correct
7 Correct 1 ms 2380 KB Output is correct
8 Correct 1 ms 2636 KB Output is correct
9 Incorrect 2 ms 3148 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 844 KB Output is correct
2 Correct 1 ms 1084 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 1212 KB Output is correct
6 Correct 1 ms 1868 KB Output is correct
7 Correct 1 ms 2368 KB Output is correct
8 Correct 1 ms 2636 KB Output is correct
9 Incorrect 2 ms 3148 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 832 KB Output is correct
2 Correct 1 ms 1080 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1868 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 1 ms 2636 KB Output is correct
9 Incorrect 2 ms 3148 KB Output isn't correct
10 Halted 0 ms 0 KB -