Submission #196834

#TimeUsernameProblemLanguageResultExecution timeMemory
196834EvirirBali Sculptures (APIO15_sculpture)C++17
0 / 100
2 ms424 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define watch(x) cout<<(#x)<<"="<<(x)<<'\n' #define mset(d,val) memset(d,val,sizeof(d)) #define setp(x) cout<<fixed<<setprecision(x) #define forn(i,a,b) for(int i=a;i<b;i++) #define fore(i,a,b) for(int i=a;i<=b;i++) #define pb push_back #define F first #define S second #define INF ll(1e18) #define MOD 998244353 #define pqueue priority_queue #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<ll,ll> ii; typedef vector<ll> vi; typedef vector<ii> vii; typedef long double ld; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds; #define MAXN 2005 int n,A,B; ll a[MAXN]; ll pre[MAXN]; void solve1() { ll dp[n+1][n+1]; fore(i,0,n) fore(j,0,n) dp[i][j]=INF; dp[0][0]=0; fore(i,1,n){ fore(j,1,n){ forn(k,0,i){ dp[i][j]=min(dp[i][j],dp[k][j-1]|(pre[i]-pre[k])); } } } ll ans=INF; fore(i,A,B){ ans=min(ans,dp[n][i]); } cout<<ans<<'\n'; } void solve2() { ll dp[n+1]; dp[0]=0; fore(i,1,n) dp[i]=INF; fore(i,1,n){ forn(j,0,i){ dp[i]=min(dp[i],dp[j]|(pre[i]-pre[j])); } } cout<<dp[n]<<'\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); mset(a,0); cin>>n>>A>>B; fore(i,1,n) cin>>a[i]; fore(i,1,n){ pre[i]=a[i]; pre[i]+=pre[i-1]; } if(A!=1) solve1(); else solve2(); return 0; }
#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...