Submission #248976

#TimeUsernameProblemLanguageResultExecution timeMemory
248976rocks03Bali Sculptures (APIO15_sculpture)C++14
21 / 100
21 ms31744 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll,ll> #define ff first #define ss second #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 2e3; int N, A, B; ll a[MAXN], DP[MAXN+1][MAXN+1]; ll f(int pos, int gruppo){ if(pos == N){ if(gruppo < A || gruppo > B) return LLONG_MAX; return 0; } if(gruppo > B || gruppo+N-pos < A) return LLONG_MAX; if(DP[pos][gruppo] != -1) return DP[pos][gruppo]; ll sum = 0, best = LLONG_MAX, res; for(int i = pos; i < N; i++){ sum += a[i]; res = f(i+1, gruppo+1); best = min(best, (sum|res)); } return DP[pos][gruppo] = best; } main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> A >> B; for(int i = 0; i < N; i++) cin >> a[i]; memset(DP, -1, sizeof(DP)); cout << f(0, 0); }

Compilation message (stderr)

sculpture.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...