Submission #707980

# Submission time Handle Problem Language Result Execution time Memory
707980 2023-03-10T16:30:06 Z ssense Bali Sculptures (APIO15_sculpture) C++14
16 / 100
86 ms 12424 KB
#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define pb push_back
#define sc second
#define fr first
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}struct prefix_sum{vint pref;void build(vint a){pref.pb(0);for(int i = 0; i < a.size(); i++){pref.pb(pref.back()+a[i]);}}int get(int l, int r){return pref[r]-pref[l-1];}};//mesanu

int dp[55][513][55];

void solve()
{
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    vint y = read(n);
    prefix_sum pref;
    pref.build(y);
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        //se termina la i grupul
        for(int j = 0; j < i; j++)
        {
            for(int orr = 0; orr <= 512; orr++)
            {
                for(int grup = 0; grup < b; grup++)
                {
                    dp[i][(orr|pref.get(j+1, i))][grup+1]|=dp[j][orr][grup];
                }
            }
        }
    }
    int ans = MX;
    for(int orr = 512; orr >= 0; orr--)
    {
        for(int grup = a; grup <= b; grup++)
        {
            ans = min(ans, (dp[n][orr][grup] ? orr : MX));
        }
    }
    cout << ans << endl;
}

int32_t main(){
    startt
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


/*
6 1 3
8 1 2 1 5 4
 */

Compilation message

sculpture.cpp: In member function 'void prefix_sum::build(std::vector<int>)':
sculpture.cpp:19:667: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 | int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}struct prefix_sum{vint pref;void build(vint a){pref.pb(0);for(int i = 0; i < a.size(); i++){pref.pb(pref.back()+a[i]);}}int get(int l, int r){return pref[r]-pref[l-1];}};//mesanu
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 7 ms 2004 KB Output is correct
7 Correct 3 ms 2132 KB Output is correct
8 Correct 4 ms 2516 KB Output is correct
9 Correct 4 ms 2560 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 2 ms 2508 KB Output is correct
12 Correct 4 ms 2516 KB Output is correct
13 Correct 13 ms 2508 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 7 ms 2004 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 6 ms 2516 KB Output is correct
22 Correct 6 ms 2516 KB Output is correct
23 Correct 6 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 7 ms 2516 KB Output is correct
26 Correct 10 ms 2516 KB Output is correct
27 Runtime error 1 ms 456 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 7 ms 1996 KB Output is correct
7 Correct 3 ms 2132 KB Output is correct
8 Correct 4 ms 2516 KB Output is correct
9 Correct 4 ms 2516 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 4 ms 2508 KB Output is correct
13 Correct 13 ms 2496 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 980 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 7 ms 2004 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 6 ms 2568 KB Output is correct
22 Correct 7 ms 2460 KB Output is correct
23 Correct 7 ms 2572 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 6 ms 2516 KB Output is correct
26 Correct 10 ms 2516 KB Output is correct
27 Correct 17 ms 2644 KB Output is correct
28 Correct 12 ms 3108 KB Output is correct
29 Correct 15 ms 4448 KB Output is correct
30 Correct 55 ms 4972 KB Output is correct
31 Correct 86 ms 5868 KB Output is correct
32 Correct 86 ms 5872 KB Output is correct
33 Correct 8 ms 5844 KB Output is correct
34 Correct 86 ms 5796 KB Output is correct
35 Correct 73 ms 5868 KB Output is correct
36 Correct 45 ms 5832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 7 ms 1996 KB Output is correct
7 Correct 3 ms 2132 KB Output is correct
8 Correct 4 ms 2636 KB Output is correct
9 Correct 4 ms 2516 KB Output is correct
10 Correct 4 ms 2548 KB Output is correct
11 Correct 2 ms 2516 KB Output is correct
12 Correct 4 ms 2516 KB Output is correct
13 Correct 13 ms 2540 KB Output is correct
14 Correct 17 ms 2604 KB Output is correct
15 Correct 12 ms 3092 KB Output is correct
16 Correct 15 ms 4564 KB Output is correct
17 Correct 56 ms 4948 KB Output is correct
18 Correct 75 ms 5932 KB Output is correct
19 Correct 85 ms 5892 KB Output is correct
20 Correct 8 ms 5844 KB Output is correct
21 Correct 86 ms 5828 KB Output is correct
22 Correct 68 ms 5836 KB Output is correct
23 Correct 45 ms 5836 KB Output is correct
24 Correct 74 ms 5968 KB Output is correct
25 Runtime error 56 ms 12424 KB Execution killed with signal 11
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 7 ms 2004 KB Output is correct
7 Correct 3 ms 2124 KB Output is correct
8 Correct 3 ms 2504 KB Output is correct
9 Correct 3 ms 2516 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 4 ms 2516 KB Output is correct
13 Correct 13 ms 2544 KB Output is correct
14 Correct 1 ms 980 KB Output is correct
15 Correct 1 ms 980 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 7 ms 1992 KB Output is correct
20 Correct 3 ms 2132 KB Output is correct
21 Correct 7 ms 2536 KB Output is correct
22 Correct 7 ms 2516 KB Output is correct
23 Correct 7 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 6 ms 2444 KB Output is correct
26 Correct 11 ms 2556 KB Output is correct
27 Runtime error 1 ms 468 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 7 ms 1876 KB Output is correct
7 Correct 3 ms 2132 KB Output is correct
8 Correct 4 ms 2516 KB Output is correct
9 Correct 4 ms 2516 KB Output is correct
10 Correct 4 ms 2504 KB Output is correct
11 Correct 2 ms 2516 KB Output is correct
12 Correct 4 ms 2508 KB Output is correct
13 Correct 13 ms 2456 KB Output is correct
14 Runtime error 1 ms 456 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -